Tried many things to make BBB connected to internet. There’re few different ways such as by enabling ethernet port or adding USB Wi-Fi dongle. But it won’t work stable when we move BBB to difference environment. Thus, I think sharing host internet is easiest way to give BBB an internet access. To make this we should route all outbound packets to this device from the BBB to the Internet via the Internet access interface.
First thing first, make USB connection between BBB and host machine.
Then check the IP address on USB port.
USB0 has 192.168.7.1 and it is a default gateway for BBB’s usb0 interface.
#Enabling traffic re-routing to Internet Access interface on host machine
#In this case, Internet traffic fro BBB’s USB0 enx4c3fd3c18fa6 will be routed to host’s Wi-Fi interface wlp10
$sudo sysctl net.ipv4.ip_forward=1
$sudo iptables --table nat --append POSTROUTING --out-interface wlp1s0 -j MASQUERADE
$sudo iptables --append FORWARD --in-interface enx4c3fd3c18fa6 -j ACCEPT