Didj Network Bridging
This page includes steps that describe how to use bridging on your host to enable your Didj to access to the wider Internet via the USB connection.
They have been tested in Ubuntu 8.04 Hardy Heron (2.6.24-26 kernel), and are based on similar instructions for other handheld devices.
- You have set up USB networking as per http://elinux.org/Didj_Networking_HOWTO
- The required tools are provided by the bridge-utils package:
sudo apt-get install bridge-utils
Configuring the Host
In this example, we assume that the host has an ethernet connectoion on eth0. (your own config may be different; for example, you may be using a Wifi adapter. In theory, aside from your LAN specific configuration, the steps outlined below should still work.)
The bridge will be made up of the host's usb ethernet link to the Didj usb0, combined with the ethernet connection eth0 in a virtual 'bridge' interface called br0.
The bridged interface br0 will be assigned the IP configuration for the PC.
(In later steps, you will assign the Didj an IP address on the same network).
Configure the host machine's /etc/network/interfaces file as follows (adjusting IP addresses as needed):
auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp auto usb0 iface usb0 inet static address 192.168.0.199 netmask 255.255.255.0 up echo 1 > /proc/sys/net/ipv4/ip_forward up iptables -P FORWARD ACCEPT up iptables -A POSTROUTING -t nat -j MASQUERADE -s 192.168.0.0/24 down echo 0 > /proc/sys/net/ipv4/ip_forward down iptables -t nat -F POSTROUTING iface br0 inet dhcp pre-up echo "Adding ethernet bridge between Didj and LAN" pre-up ifconfig eth0 0.0.0.0 pre-up brctl addbr br0 pre-up brctl setfd br0 0 pre-up brctl stp br0 off pre-up brctl addif br0 eth0 pre-down echo "Removing ethernet bridge between Didj and LAN" post-down brctl delif br0 eth0 post-down brctl delbr br0 post-down ifdown eth0 post-down ifup eth0
To apply these new settings:
On the Host:
sudo /etc/init.d/networking restart
(of course, rebooting the host will also work)
If you are using DHCP as we do in the above example, make a note of your br0 ip address by typing ifconfig.
Configuring the Didj
If you are using a standard Didj configuration and you have not yet done so, rmmod the g_file_storage kernel module and insmod the g_ether/ko module. (see http://elinux.org/Didj_Networking_HOWTO#Installing_g_ether.ko)
With the USB cable connected to your host, configure an IP address on the same subnet as the rest of your LAN
On the Didj:
ifconfig usb0 192.168.0.200 netmask 255.255.255.0
At this point, activate your bridge on the host by entering:
On the Host:
sudo ifup br0
Next, add a route from your Didj to the host (making it the gateway) using the ip address you found for br0 via running ifconfig on the host.
On the Didj:
route add default gw 192.168.0.116 usb0
Finally, add nameservers to your Didj's /etc/resolv.conf file (you can add the lines from this example which uses the OpenDNS servers)
nameserver 22.214.171.124 nameserver 126.96.36.199
At this point, assuming br0 is brought up on your host, your Didj is connected to the outside world - and a ping or a wget to yahoo or google should work.