In a previous blog post I wrote about a little experiment I did with a BeagleBone Black and a Neato LIDAR. Eventually I plan to use these parts to build an autonomous wheeled robot, but I realized that before I go much further it would be a good idea for the BeagleBone Black to have internet connectivity, ideally wireless. This will not only greatly simplify the process of installing various software packages, but it will also allow me to SSH to the BeagleBone Black over my local WiFi network.
In this blog post, I’m going to keep it simple and just explain how I setup the BeagleBone Black to share my laptop’s internet connection over USB. This makes it easier to setup a wireless internet connection, which will be the topic of another blog post.
First Things First
First of all, you will need to make sure that you can establish an SSH connection to the BeagleBone Black. If you haven’t already done so, you can find instructions for SSH Setup on the Adafruit website.
I have only tested this setup on a BeagleBone Black running the Debian operating system, so you may want to do the same if you are going to follow the steps that I took. The latest images of the Debian OS can be found here. The image that I used was dated 2014-04-23. To check the version installed, run the following command on the BeagleBone Black.
Setup Internet Sharing on Windows
My laptop is running Windows 8.1, so I have not taken the time to find the steps needed to setup internet sharing for any other operating systems.
- Open the control panel, and search for “network connections” in the search box. Click “View Network Connections” in the results.
- Right-click the internet connection to share with the BeagleBone Black and select Properties. Navigate to the Sharing tab.
- Select the option to “Allow other network users to connect through this computer’s Internet connection”.
- Select the BeagleBone Black’s network connection from the dropdown and then click OK.
- Now go back to Network Connections and right click the BeagleBone Black’s network connection, and select Properties.
- Click “Internet Protocol Version 4 (TCP/IPv4)” in the list and select Properties.
- Select the options to “Obtain an IP address automatically” and “Obtain DNS server address automatically”, and click OK.
Setup Internet Sharing on BeagleBone Black
Through an SSH connection to the BeagleBone Black, run the following commands.
route add default gw 192.168.7.1 echo "nameserver 18.104.22.168" >> /etc/resolv.conf
Test the internet connection by pinging a website:
If that worked, congratulations! Your BeagleBone Black now has internet access.
Persisting the Internet Connection Settings
There is one last step to complete so that the internet connection works even after the device is rebooted.
Run this command to edit one of the scripts that runs when the device boots.
Scroll down until you see the following lines.
/sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252 /usr/sbin/udhcpd -S /etc/udhcpd.conf
Immediately after those lines, add the following line.
/sbin/route add default gw 192.168.7.1 metric 1
Be sure to save the file before closing it.
That’s all there is to it. For further reading on this topic, see this blog post and this article. In a later blog post I will explain how to setup the BeagleBone Black with wireless network connectivity.