Thursday, June 20, 2013

Windows 7 Internet Sharing for BeagleBone Black

I wish I better understood WHY this was necessary.  

At one point my BBB "just worked".  When it was plugged into my desktop computer via USB (Windows 7 machine) the BBB had internet connectivity just fine.  After working to solve other issues it stopped.  In any case, it works again with the following steps:


On the Windows 7 computer:

  •     Control Panel -> Network and Internet -> Network Connections
  •     Right-click your internet connection, Properties, Sharing Tab
  •     Click "Allow other network users to connect thru this computer's Internet connection"
  •     Select the BeagleBone Black's network connection under "Home networking connection:"
  •     Click OK.

    Here's the trick:  when I did this, Windows assigned a static IP to the BBB connection.  Why?  No idea.  
    You have to go back to that connection and reset it to DHCP.

  •     Control Panel -> Network and Internet -> Network Connections
  •     Right-click the BeagleBone Black's connection, Properties
  •     Click Internet Protocol Version 4 (TCP/IPv4), Click Properties
  •     Click "Optain an IP address automatically"
  •     Click "Obtain DNS server address automatically"
  •     Click OK.  Click CLOSE.

On the BBB:

This makes the BBB route internet traffic thru the host (Windows 7 in this case) and DNS thru Google's DNS Servers (8.8.8.8).  

    route add default gw 192.168.7.1
    echo "nameserver 8.8.8.8" >> /etc/resolv.conf

Try It:

    ping www.google.com

Make it Persistant:

To make this "stick" after a reboot of the BBB, you need to add these commands to the ethernet startup script on the BBB (/usr/bin/g-ether-load.sh).  

NOTE:   You CANNOT simply add these commands to the bottom of that script file.  They must go  before the udhcpd starts.  It does not return control to the script so adding them at the bottom of the file does nothing for you.  My script file now looks like this:

    /sbin/ifconfig usb0 192.168.7.2 netmask 255.255.255.252
    /sbin/route add default gw 192.168.7.1
    echo 'nameserver 8.8.8.8' >> /etc/resolv.conf


    /usr/sbin/udhcpd -f -S /etc/udhcpd.conf


IT WORKS!


A big thanks to robert@rplural.net who got me moving in the right direction.  Read his description of the parallel steps for a Linux host!

    

14 comments:

  1. Amazing!!! I was stuck with this for a long time! Thanks a ton for sharing this!!!

    ReplyDelete
    Replies
    1. @sneha: hii .. are you using the BBB board ??

      Delete
  2. Can we do this on Windows vista.?
    I have USB 3G connection & Vista / Ubuntu 12. Please post procedure to share connection in either OS.

    ReplyDelete
    Replies
    1. I am sorry but I do not have nor do I know Windows Vista.

      Delete
  3. This comment has been removed by the author.

    ReplyDelete
  4. THANK YOU!! I looked everywhere to get this to work, I tried bridging the connections, but that flopped. I didn't think of doing it this way. Thanks for saving me hours of trolling through the internet!

    ReplyDelete
  5. this worked fine for angstrom but it didn't work for ubuntu 13.10 . please help !!

    ReplyDelete
  6. Hi, I'm running Ubuntu in my BBB and there is no /usr/bin/g-ether-load.sh in Ubuntu, could you help me?

    ReplyDelete
    Replies
    1. I'm running Debian on my BBB and I didn't find the /usr/bin/g-ether-load.sh file either. I was able to get it to work by editing the /opt/scripts/boot/am335x_evm.sh file.

      Look for the following lines towards the bottom of that file:

      /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

      That worked for me.

      Delete
  7. Ita a really a nice blog. This blog help you for solve your windows 7 related problem ,and its fix you error . please visit this link .
    windows 7 problems
    Thank you
    Aalia lyon

    ReplyDelete
  8. Just tried this on a bbb running ubuntu 13.04 linked to a win7 pc. Works great. Many thanks!

    ReplyDelete