Is normal Network Routing supposed to work in USB tethered mode?

I don’t use normally my BBB with USB tethering … I just connect it to my network via ethernet and then ssh into it.

In an effort to try and reproduce some of the problems others have reported here, I decided to connect one of my BBBs via USB to my Mac.

After installing the drivers on the Mac, it all seemed to work as expected. I was able to point my browser at http://192.168.7.2/ and I was able to ssh into it as root.

However, I also noticed that it doesnt seem like it set up the network routes properly.

The BBB is running the latest upgrade (eMMC Flasher 2013-05-08), followed by an opkg update+upgrade.

root@beaglebone:~# uname -a
Linux beaglebone 3.8.12 #1 SMP Sat May 11 08:21:34 CEST 2013 armv7l GNU/Linux

I can ping the gateway just fine:

root@beaglebone:~# ping 192.168.7.1
PING 192.168.7.1 (192.168.7.1) 56(84) bytes of data.
64 bytes from 192.168.7.1: icmp_req=1 ttl=64 time=0.281 ms
64 bytes from 192.168.7.1: icmp_req=2 ttl=64 time=0.428 ms
^C
— 192.168.7.1 ping statistics —
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.281/0.354/0.428/0.075 ms
root@beaglebone:~#

but the routing table seems weird:

root@beaglebone:~# route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.7.0 * 255.255.255.252 U 0 0 0 usb0
root@beaglebone:~#

And sure enough, neither dns lookups nor pings to outside seem to work

root@beaglebone:~# ping www.google.com
ping: unknown host www.google.com
root@beaglebone:~# ping 74.125.239.116 # aka www.google.com
connect: Network is unreachable
root@beaglebone:~#

I would have assumed this is supposed to work, but I don’t know if this is a consequence of my upgrade. Is this what I am supposed to be seeing?

Thx!

That’s what mine looked like in Angstrom as well. I think by default it sets up a very restrictive netmask and no there is no default route so setting up internet sharing on the Mac for that interface won’t work because it doesn’t know where to send packets that are outside that netmask.

It is just another network interface so assuming you can locate all the pieces to the puzzle in Angstrom you should be able to get the default route setup and connect through the MAC to the internet. I installed Arch Linux and after getting the USB Ethernet to come up at boot I just used the normal config files to set a static IP and gateway and the same on the Mac side and it all worked fine.

I got this to work on Angstrom by modifying the /usr/bin/g-ether-load.sh script which sets up the USB Ethernet connection. I added 2 lines at the end of the file:

/sbin/route add default gw 192.168.7.1
echo “nameserver 8.8.8.8” >> /etc/resolv.conf

This adds a default gateway for the network carried over USB and adds a DNS server for resolving names - 8.8.8.8 is Google - change it to a local DNS server or your favorite external one as needed.

You could also do this manually each time it’s needed rather than every time via the g-ether-load.sh script.

I don’t know if there is a better way to do this without modifying g-ether-load.sh. There might a more “correct” way using systemd or connman but I’m still learning those.

On the host side running Ubuntu, I enable forwarding via the following two commands:

sudo iptables -A POSTROUTING -t nat -j MASQUERADE
sudo echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward > /dev/null

Note that these need to be run each time you re-boot the host, either manually or via some init script.

Kyle: any tips/advice on getting this going on the Mac? I tried enabling “Internet Sharing” via the GUI on Mac OSX 10.8, but nothing gets through from the BBB. I can ping the Mac from the BBB and ssh into the BBB from the Mac so the connection is up. Do you use the command-line ipfw command to set this up?

Mark

I was able to accomplish something similar using Windows 7 and it’s Internet Connection Sharing.
See: http://lanceme.blogspot.com/2013/06/windows-7-internet-sharing-for.html

Thanks!
Carl Lance

I have spent a lot of time trying to share a Mac’s Internet connection with a BeagleBone Black while connected via USB. I am able to do this without any difficulty just using the Mac Gui on a machine running OSX 10.6.8. On a machine running OSX 10.7.5, I can make it work, but I have to run the following commands on the host:

  • sudo su
  • ifconfig en3 192.168.7.1 (where en3 is the BBB’s interface)
  • sysctl -w net.inet.ip.fw.enable=1
  • sysctl -w net.inet.ip.forwarding=1
  • natd -interface en1 (where en1 is the interface for the Mac’s Internet connection)
  • ipfw add divert natd ip from any to any via en1
    This is all I have to do if I’m using my older Linksys router or if I’m tethered to my cell phone, but if I use a newer Netgear router, then I have to enable Internet Sharing through the GUI as well. If I download and install Mavericks OSX 10.9.2, I cannot share Internet when using the Netgear router, but I can share Interent when the Mac is tethered to my phone (haven’t tested this with my Linksys yet). At Any rate, it looks as though sharing a Mac’s Internet connection using the commands above is dependent on the network. I would love to see a method that works no matter what kind of network the Mac is connected to. FYI, I’m using the Jaoshua Wise’s latest RNDIS driver (rel5).