Forked from RobertCNelson/gist:3e526af326660604a71f
Last active
August 29, 2015 14:23
-
-
Save jadonk/536b6550a63723ff2016 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# if (a device is currently using 192.168.7.2) then | |
# Use 192.168.8.x on the host downstream port and slave upstream port | |
cat <<LOCAL_END >>/etc/network/interfaces | |
iface eth1 inet static | |
address 192.168.8.1 | |
netmask 255.255.255.252 | |
network 192.168.8.0 | |
LOCAL_END | |
iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE | |
iptables --append FORWARD --in-interface eth1 -j ACCEPT | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
# configure /dev/ttyACM0 and login | |
cat <<HOST_END >/dev/ttyACM0 | |
cat <<DEVICE_END >>/etc/network/interfaces | |
iface usb0 inet static | |
address 192.168.8.2 | |
netmask 255.255.255.252 | |
network 192.168.8.0 | |
gateway 192.168.8.1 | |
DEVICE_END | |
echo "nameserver 8.8.8.8" >> /etc/resolv.conf | |
route add default gw 192.168.8.1 | |
HOST_END | |
# else | |
# Use 192.168.7.x on the host downstream port and slave upstream port | |
dhclient eth1 | |
iptables --table nat --append POSTROUTING --out-interface usb0 -j MASQUERADE | |
iptables --append FORWARD --in-interface eth1 -j ACCEPT | |
echo 1 > /proc/sys/net/ipv4/ip_forward | |
# configure /dev/ttyACM0 and login | |
cat <<HOST_END >/dev/ttyACM0 | |
echo "nameserver 8.8.8.8" >> /etc/resolv.conf | |
route add default gw 192.168.7.1 | |
HOST_END | |
# endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment