Difference between revisions of "BBB Internet over the USB cable"

From Klaus' wiki
Jump to: navigation, search
Line 41: Line 41:
 
At first login on the BBB execute this script as root (or use sudo).  
 
At first login on the BBB execute this script as root (or use sudo).  
  
 +
===Automating the script===
 
You may want to set this script up so it will be executed at boot time. In order to do this you'll have to setup a boot script in /etc/init.d - you may want to call it internetOverUSB. Enter ths into the script.
 
You may want to set this script up so it will be executed at boot time. In order to do this you'll have to setup a boot script in /etc/init.d - you may want to call it internetOverUSB. Enter ths into the script.
  

Revision as of 08:57, 22 February 2016

It is rather easy to get access to the whole internet over the USB interface cable provided that your laptop/PC has internet access.

If you're running Linux you can follow these instructions.

If you're running Windows Derrek Molloy has some advices on this page.

On the BBB create this file and make it executable

#!/bin/bash
# 
# Author : Klaus Kolle
#   Date : 2016 02 22
# Purpose: Establishing connection to the Internet
# and set the clock, which has no battery backup
#
 
echo "Starting the Internet-over-USB script"
 
## Add a default gateway 
/sbin/route add default gw 192.168.7.1
grep -q 8.8.8.8 /etc/resolv.conf
if [ "$?" -ne "0" ]; then
        echo "nameserver 8.8.8.8" >> /etc/resolv.conf
fi
 
## Test for network availability
while :
do
        ping -c 5 -w 10 192.168.7.1
        if [ $? -eq 0 ]; then
                break
        fi
done
 
## Now we should be ready to set the clock from the net
/usr/sbin/ntpdate -b -s -u dk.pool.ntp.org
date
echo "End of the settings script"

At first login on the BBB execute this script as root (or use sudo).

Automating the script

You may want to set this script up so it will be executed at boot time. In order to do this you'll have to setup a boot script in /etc/init.d - you may want to call it internetOverUSB. Enter ths into the script.

#! /bin/sh
 
### BEGIN INIT INFO
# Provides: InternetOverUSB
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Enables Internet over USB cable
# Description: Enables access to the Internet over the Internet connection 
provided by the connected host
### END INIT INFO
case "$1" in
        start)
                sleep 20
                /root/internetOverUSB
        ;;
        stop)
                #no-op
        ;;
        *)
                #no-op
        ;;
esac
 
exit 0

Now execute

$] chmod 755 /etc/init.d/internetOverUSB

The 20 seconds sleep is for the laptop being able to establish its network settings. May be adjusted to suit your OS an laptop specific needs.

Finally enable the script.

$] update-rc.d internetOverUSB defaults

Try to reboot and login again. Check that the date now is correct. If not debug your scripts.