USB Networking troubles

Andrew C. Dingman andrew+openmoko at
Fri Aug 8 14:40:53 CEST 2008

On Fri, 2008-08-08 at 06:32 -0400, michael cole wrote:
> First thanks to all for replying.
> These changes worked.

Glad it helped. I hope the IP routing mini-lecture made clear *why* :)

> So on my Freerunner /etc/network/interfaces includes:
> # Ethernet/RNDIS gadget (g_ether)
> # ... or on host side, usbnet and random hwaddr
> auto usb0
> iface usb0 inet static
> 	address
> 	netmask
> 	network
> 	gateway
> # orig:
> #	up echo nameserver >/etc/resolv.conf
> # using home (
> 	up echo nameserver >/etc/resolv.conf
> on the desktop  /etc/network/interfaces includes:
> allow-hotplug usb0
> iface usb0 inet static
>         address
>         netmask
>         post-up iptables -A POSTROUTING -t nat -j MASQUERADE -s
>         post-up echo 1 > /proc/sys/net/ipv4/ip_forward
>         post-up iptables -P FORWARD ACCEPT
>         pre-down iptables -D POSTROUTING -t nat -j MASQUERADE -s

Almost right, and in fact this configuration won't break in practice
because you can't plug additional devices into your USB network.
However, the FreeRunner and the desktop really *should* agree about the
netmask. You have the FreeRunner thinking its local network includes 256
addresses (, and the desktop thinking that the network
it and the FreeRunner live in includes only 64 ( If
you choose to fix this on the desktop by using the
netmask, you'll also want to fix the masquerade rule to specify, as the /n part indicates a netmask with binary 1 in
the n most significant bits. ( == binary IP 11111111
11111111 11111111 00000000. == binary 11111111 11111111
11111111 11000000)

If you want to play with this stuff a bit more, you might be interested
in a tool called 'gip' that you can install on your desktop with
'apt-get install gip'. It lets you enter IPs and netmasks in any of the
normal forms and shows you the resulting network sizes and binary,
hexadecimal, and decimal representations of the results.

More information about the support mailing list