Last active
April 1, 2019 10:56
-
-
Save zankich/6e2522dcb93afb94abae to your computer and use it in GitHub Desktop.
connect to your beaglebone black using the usb->ethernet and forward the internet from your host computer to the beaglebone black
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# run this script on your linux host computer to connect to the bbb and forward your internet. | |
# be sure to replace "enp0s20u1" with the appropriate usb device for your bbb, which can be found | |
# by doing an "ifconfig" on your host computer. | |
# | |
sudo -- sh -c 'echo 1 > /proc/sys/net/ipv4/ip_forward' | |
sudo iptables -A POSTROUTING -t nat -j MASQUERADE | |
sudo ifconfig enp0s20u1 192.168.7.1 255.255.255.0 | |
ssh [email protected] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# run this script on your bbb to use the internet forwarded from your host linux computer | |
# | |
ROUTE=`route | grep 0.0.0.0 | wc -l` | |
if [ $ROUTE -eq 0 ] | |
then | |
sudo -- sh -c 'echo "nameserver 8.8.8.8" >> /etc/resolv.conf' | |
sudo /sbin/route add default gw 192.168.7.1 | |
sudo ntpdate ntp.ubuntu.com | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Had some issues with a few of the lines in bbb_connect.sh
The iptables line
sudo iptables -A POSTROUTING -t nat -j MASQUERADE
stopped webpages from loading on my host machine. It seems like an outgoing interface is required to prevent the issue. For others following along, revert the setting withsudo iptables --table nat --flush
.The ifconfig line
sudo ifconfig enp0s31f6 192.168.7.1 255.255.255.0
returned anSIOCSIFADDR: Invalid argument
error. This line doesn't seem critical anyway, since192.168.7.1
is already listed as my USB interface IP.Some of the commands on this page worked a bit better for me.
My final script ended up being the following:
In the internet_sharing.sh script, the
ntpdate
line doesn't seem necessary anymore on the latest image (debian 9.5).ntpdate
was replaced byntpd
, and then bytimedatectl
. Runningtimedatectl
on the beaglebone shows the time in-sync.