2015-04-02 19:00:22 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
set -v
|
2015-04-02 19:49:05 +01:00
|
|
|
if [[ -z "$USB_INTERFACE" ]]; then
|
|
|
|
USB_INTERFACE=usb0
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z "$INTERNET_INTERFACE" ]]; then
|
|
|
|
INTERNET_INTERFACE=wlan0
|
|
|
|
fi
|
2015-04-02 19:00:22 +01:00
|
|
|
|
|
|
|
sudo /sbin/ip link set $USB_INTERFACE up
|
|
|
|
|
|
|
|
sudo /sbin/ip addr add 10.0.0.2/24 dev $USB_INTERFACE
|
|
|
|
|
|
|
|
sudo /sbin/iptables -t nat -A POSTROUTING -s 10.0.0.1/32 -o $INTERNET_INTERFACE -j MASQUERADE
|
|
|
|
|
|
|
|
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
|
|
|
|
|