How to enable DHCP on USB gadget

By | March 26, 2012

I have spent a couple of days scratching my head while trying to configure USB network gadget adapter. The platform is OpenEmbedded Linux on AT91, connected to a Windows 7 PC. Here we go:

The first small problem was that the network connection shows up as ‘cable disconnected’ in Windows. It is solved by putting auto usb0 to /etc/network/interfaces

Next, configuring DHCP server for automatic IP address. In my setup, I have a fixed IP address for the USB network connection in the Linux box. The embedded DHCP server (dnsmasq) assigns an address in the same subnet to the PC connected via USB.

In /etc/dnsmasq.conf (or recipes/dnsmasq/files/dnsmasq.conf), put the interface to listen to and the IP address range in the appropriate places:


It seems that there is an issue in dnsmasq – when the USB cable is plugged in after dnsmasq is started, IP address is still not assigned. I solved it (at least temporarily) by restarting dnsmasq in /etc/network/interfaces:

auto usb0
iface usb0 inet static
# enable if the host is a gateway
#        gateway
        post-up /etc/init.d/dnsmasq restart

Leave a Reply

Your email address will not be published.