HowTos/Bridging with Gentoo
From OpenZaurus
This describes how to give network access to your Zaurus via ethernet bridging with a PC running Gentoo Linux. This allows a USB-connected Zaurus to appear as another host on the same network as the PC. Bridging is useful only if you can allocate an IP address for the Zaurus that is on the same network as the PC (e.g. you are connected to a private network). Bridging is not appropriate if your PC is connected directly to the internet (via a cable/adsl/modem) and thus has a public IP address, in this case see this howto.
Contents |
Prerequisites for Gentoo host machine
- Bridging is supported in the current 2.4 and 2.6 kernels. If you configure your own, you need CONFIG_BRIDGE together with whatever kernel options are necessary to get usbnet working with your Zaurus, for a SL-5500 (collie) these are CONFIG_USB_USBNET and CONFIG_USB_NET_ZAURUS. I compiled all these as modules and they get loaded automatically when required.
- baselayout-1.11.11 or later
- The brctl command is provided by the bridge-utils package:
emerge -n net-misc/bridge-utils
Configuring the Gentoo machine
The interface with the Zaurus, usb0, will be combined with eth0 in a virtual interface called br0, this is what will be assigned the IP configuration for the PC.
First you need to tell the Gentoo RC system about usb0 and br0 (I'll assume eth0 is already configured). This is done by creating symbolic links from net.lo to net.usb0 and net.br0 in /etc/init.d.
cd /etc/init.d ln -s net.lo net.usb0 ln -s net.lo net.br0
Next you tell Gentoo how to configure the interfaces. This is done in /etc/conf.d/net. With baselayout-1.11.x, this should contain:
# Add eth0 to the bridge. usb0 will be added by hotplug when it comes up.
bridge_br0="eth0"
# Make sure eth0 gets configured before the bridge.
depend_br0() {
need net.eth0
}
# Ensure that eth0 and usb0 don't get configured by DHCP
# The only interface needing IP configuration is br0
config_eth0=( "null" )
config_usb0=( "null" )
# Give the bridge an IP configuration, either static:
config_br0=( "192.168.2.10/24" )
gateway="br0/192.168.2.1"
# or by DHCP:
# config_br0=( "dhcp" )
# This is the address by which the Gentoo machine will be known on the network
# When you plug in the Zaurus, hotplug creates the usb0 interface and
# issues a network hotplug event which causes Gentoo to configure the
# interface. This function causes it to be added to the bridge:
postup() {
local iface=${1}
if [ ${iface} == usb0 ]; then
brctl addif br0 ${iface}
elif [ ${iface} == br0 ] && ifconfig -a | grep usb0 > /dev/null ; then
# if usb0 is already present when br0 is configured (i.e. the
# Zaurus was plugged in and switched on when the PC was booted
# then add it to the bridge.
brctl addif br0 usb0
fi
}
With baselayout-1.12 and later this simplifies to:
# Add port to bridge br0
bridge_br0="eth0"
# dynamically add usb0 when the interface comes up
bridge_add_usb0="br0"
# Configure the ports to null values so dhcp does not get started
config_eth0=( "null" )
config_usb0=( "null" )
# Give the bridge an address - dhcp
config_br0=( "dhcp" ) # or e.g. ( "192.168.2.0/24" ) for static config
# make sure eth0 is up before configuring br0
depend_br0() {
need net.eth0
}
Obviously change the IP addresses to suit.
Configuring the Zaurus
Use the Network settings GUI to configure usbd0. Either use DHCP, or a static config on the same subnet as the PC, e.g.:
Automatically bring up IP Address = 192.168.2.50 Subnet Mask = 255.255.255.0 Gateway = 192.168.2.1 (same as the PC) First DNS = 192.168.2.10 (same as the PC) Second DNS = 192.168.2.1 (same as the PC)
Test the configuration
On the Gentoo box:
/etc/init.d/net.eth0 pause /etc/init.d/net.br0 start
Then plug in and switch on the PDA and check that both the PC and the PDA have network access.
Make the configuration permanent
On the Gentoo box:
rc-update del net.eth0 rc-update add net.br0 default
Troubleshooting
I found that the MTU assigned to usbd0 on the Zaurus was diferent from that assigned to usb0 on the PC:
gentoo # ifconfig usb0
usb0 Link encap:Ethernet HWaddr 66:5E:F2:2A:07:79
UP BROADCAST RUNNING MULTICAST MTU:1494 Metric:1
RX packets:198 errors:0 dropped:0 overruns:0 frame:0
TX packets:3368 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:20256 (19.7 Kb) TX bytes:349616 (341.4 Kb)
collie # ifconfig usbd0
usbd0 Link encap:Ethernet HWaddr 40:00:01:00:00:01
inet addr:192.168.2.50 Bcast:192.168.2.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3459 errors:2 dropped:2 overruns:0 frame:2
TX packets:251 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
This does not prevent logging into the Zaurus using ssh but does prevent downloading files larger than about 1kB. I am not sure why this happens, it may be related to this kernel bug report
The solution is to reduce the MTU on the Zaurus end. You can configure the Zaurus to do this automatically by editing /etc/network/interfaces. Find the section starting 'iface usbd0' and add the following line:
up ifconfig usbd0 mtu 1494

