-
Notifications
You must be signed in to change notification settings - Fork 0
howto share inet usb howto
Fanda Vacek edited this page Jun 26, 2017
·
4 revisions
SSH to BB
sudo ip addr add 192.168.7.1/30 dev eth4
ssh [email protected]
On BB
# add default route to the host
ip route add default via 192.168.7.1
On host (desktop)
- find using
ip addr
name of interface with address192.168.7.1
. It iseth6
in my case - find interface providing the internet access. It is
wlan0
in my case, can beppp0
or different, if one is using VPN.
make-nat.sh eth6 wlan0
make-nat.sh
#!/bin/sh
help_exit()
{
echo $0 "LAN_interface WAN_interface"
echo "Example: " $0 " eth6 wlan0"
exit 1
}
IF_IN=$1
if [ -z $IF_IN ]; then
help_exit
fi
IF_OUT=$2
if [ -z $IF_OUT ]; then
help_exit
fi
# forward NAT packets to the interface wlan0
sudo iptables --table nat --append POSTROUTING --out-interface $IF_OUT -j MASQUERADE
# accept packet forwarding from interface eth6
sudo iptables --append FORWARD --in-interface $IF_IN -j ACCEPT
# enable packet forwarding in system
echo "1" | sudo tee /proc/sys/net/ipv4/ip_forward 1>/dev/null
Now you are able to test internet connection on BB
ping 8.8.8.8
ping google.com
You might have to add DNS addres to resolv.conf
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf 1>/dev/null