I am making the following assumptions:
- eno1 is the name network interface that is connected to the internet
- enp12s0 is the name of the network interface on the BBB
- The subnet used is 192.168.123.0 / 255.255.255.0
Your configuration might be different, and you have to adjust the steps below accordingly.
To configure the host PC that shared internet connection, first enable the network interface that is connected to the BBB and and set its IP address:
# ip link set up dev net0 # ip addr add 192.168.123.1/24 dev enp12s0
Then enable packet forwarding:
# sysctl net.ipv4.ip_forward=1
To make the forwarding settings persistent, a sysctl configuration file must be created:
# nano /etc/sysctl.d/30-ipforward.conf net.ipv4.ip_forward=1 net.ipv6.conf.default.forwarding=1 net.ipv6.conf.all.forwarding=1
Now enable network address translation (NAT) on the interface that is connected to the internet:
# iptables -t nat -A POSTROUTING -o eno1 -j MASQUERADE # iptables -A FORWARD -i enp12s0 -o eno1 -j ACCEPT # iptables -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
The host PC will now forward relevant traffic from the BBB to the internet.
Configure a static IP address and route:
# ip addr add 192.168.123.100/24 dev eth0 # ip link set up dev eth0 # ip route add default via 192.168.123.1 dev eth0
Then configure any DNS servers, if needed (I use Google’s):
# nano /etc/resolv.conf nameserver 18.104.22.168
The BeagleBone Black should now be able to access the internet.