Skip to content

Instantly share code, notes, and snippets.

@arainho
Created May 18, 2022 07:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arainho/15d8c4d7ed489d6b1d0d24cca834e506 to your computer and use it in GitHub Desktop.
Save arainho/15d8c4d7ed489d6b1d0d24cca834e506 to your computer and use it in GitHub Desktop.
Share Raspberry LAN internet with usbarmory
#!/bin/bash
WAN_IFACE="eth0"
USB_IFACE="usb0"
# apply config's
ip addr del 169.254.177.31/16 dev usb0
ip addr add 10.0.0.2/255.255.255.0 broadcast 10.0.0.255 dev usb0
sysctl net.ipv4.ip_forward=1
sysctl net.ipv6.conf.default.forwarding=1
sysctl net.ipv6.conf.all.forwarding=1
sysctl net.ipv4.conf.usb0.forwarding=1
sysctl net.ipv6.conf.usb0.forwarding=1
iptables -t nat -A POSTROUTING -o "${WAN_IFACE}" -j MASQUERADE
iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -i "${USB_IFACE}" -o "${WAN_IFACE}" -j ACCEPT
# show current settings
ip r s
ip a show usb0
iptables -nvL -t nat
sysctl net.ipv4.ip_forward
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment