Sharing Internet with the BeagleBone Black over its usb network interface
Here is the scenario:
* My Ubuntu computer has access to the Internet through wifi (wlan0).
* I connect my BeagleBone Black to my host computer using the usb cable, and the usb network is on.
* The ip addresses of the usb network connection are:
+ Ubuntu computer: 192.168.7.1
+ BeagleBone Black: 192.168.7.2
* But when I log into the BBB, it cannot go out to the Internet.
So, I will attempt to share my Ubuntu's wifi connection to the BBB via the usb network connection:
1. SSH to the BBB:
ssh debian@192.168.7.1
2. In the BBB console type the following:
sudo ifconfig usb0 192.168.7.2
sudo route add default gw 192.168.7.1
3. In the linux console of host system (Ubuntu) type:
sudo su
#wlan0 is my internet facing interface, eth1 is the BeagleBone USB connection
ifconfig eth1 192.168.7.1
iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
4. Set the DNS server address in the BBB console:
echo "nameserver 8.8.8.8" >> /etc/resolv.conf
Cool!
* My Ubuntu computer has access to the Internet through wifi (wlan0).
* I connect my BeagleBone Black to my host computer using the usb cable, and the usb network is on.
* The ip addresses of the usb network connection are:
+ Ubuntu computer: 192.168.7.1
+ BeagleBone Black: 192.168.7.2
* But when I log into the BBB, it cannot go out to the Internet.
So, I will attempt to share my Ubuntu's wifi connection to the BBB via the usb network connection:
1. SSH to the BBB:
ssh debian@192.168.7.1
2. In the BBB console type the following:
sudo ifconfig usb0 192.168.7.2
sudo route add default gw 192.168.7.1
3. In the linux console of host system (Ubuntu) type:
sudo su
#wlan0 is my internet facing interface, eth1 is the BeagleBone USB connection
ifconfig eth1 192.168.7.1
iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE
iptables --append FORWARD --in-interface eth1 -j ACCEPT
echo 1 > /proc/sys/net/ipv4/ip_forward
4. Set the DNS server address in the BBB console:
echo "nameserver 8.8.8.8" >> /etc/resolv.conf