Beaglebone Black - Internet Over USB

From EdWiki

Revision as of 08:10, 10 December 2020 by Jshankar (Talk | contribs) (HOST machine)

  • Beaglebone board can communicate to the internet over USB cable by sharing your PC's internet connection
  • You need not use a separate Ethernet cable to connect your board to internet
  • The required drivers are enabled by default in the kernel and loaded when Linux boots on the BBB.
  • But you must enable internet sharing on your HOST

Target Settings

  1. Add name server address in: /etc/resolv.conf
  2. Add name server address in: /etc/network/interfaces
    iface usb0 inet static
  3. Add default gateway address by running the below command
    sudo route add default gw (Using PC as default gateway)
    Run the above command every time you reboot your BBB

HOST machine

  • create script file and add the following lines and save it
    iptables --table nat --append POSTROUTING --out-interface wlp3s0 -j MASQUERADE
    iptables --append FORWARD --in-interface wlp3s0 -j ACCEPT
    echo 1 > /proc/sys/net/ipv4/ip_forward

Run this script file every time you reboot/start your Host

jshankar@emsys:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc fq_codel state DOWN group default qlen 1000
    link/ether ec:f4:bb:1c:f7:4f brd ff:ff:ff:ff:ff:ff

3: wlp3s0:<BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000

   link/ether c4:d9:87:68:33:46 brd ff:ff:ff:ff:ff:ff
   inet brd scope global dynamic noprefixroute wlp3s0
      valid_lft 3054sec preferred_lft 3054sec
   inet6 2401:4900:3303:630a:d0e:30fc:ef4:b3bc/64 scope global temporary dynamic 
      valid_lft 2308sec preferred_lft 2308sec
   inet6 2401:4900:3303:630a:6f56:1355:46c3:e232/64 scope global dynamic mngtmpaddr noprefixroute 
      valid_lft 2308sec preferred_lft 2308sec
   inet6 fe80::e5b7:87ab:1b90:b333/64 scope link noprefixroute 
      valid_lft forever preferred_lft forever