Skip to main content

Android 2.2 with Classless Static Routes

I have a second network at home for my virtual machines and DHCP is set up to give the classless routing information. I usually use 3G connection but today I enabled WiFi on my android phone running 2.2 and it brought the WiFi up but no hosts could be accessed. It turned out that it did not want to set the default route.

It turns out that Android actually implements it the right way:

If the DHCP server returns both a Classless Static Routes option and a Router option, the DHCP client MUST ignore the Router option.

RFC 3442 – The Classless Static Route Option for Dynamic Host Configuration Protocol (DHCP) version 4

Oh, so my network is broken! I added the default route to the classless static route (which immediately triggered a bug in network manager, which is not that critical – the gateway is still picked up from the router option) but now my phone failed to get the DNS.

After forcing dhcp option 6 with the ip address of my DNS server the phone finally connected to the outside world via WiFi.

So now my dnsmasq uci config started to look like this and it works for me:

config 'dhcp' 'lan'
    ...
    # option 121
    list 'dhcp_option' 'option:classless-static-route,192.168.100.0/24,192.168.1.10,0.0.0.0/0,192.168.1.1'
    # option 6
    list 'dhcp_option' 'option:dns-server,192.168.1.1'