FORUMS

Problem with getting DHCP lease from dnsmasq

6 posts
Thanks Meter: 0
 
By yasn77, Junior Member on 19th February 2010, 12:40 PM
Post Reply Email Thread
I originally posted this in the Nexus One Forum... But recently bought my wife the Hero, and discovered the problem is also with that... So thinking now the problem is more general and Android related......

I have a weird problem.... My home network uses dnsmasq to provide DNS/dhcp. When i try to connect my phone via wifi, i get associated ok... also get IP+GW... BUT no DNS servers(!?). My previous phones (HTC Touch HD and Kaiser) never had this problem.

If i setup static IP, then all works ok.... So far i only have seen this problem at home, hence i believe it is dnsmasq related.

So... just wondering if anyone has come across a similar issue... or any ideas on how i can diagnose this. Haven't really done much diagnosing on Android yet, was hoping for a a few pointers.... Like how does Android handle DHCP... i am guessing it doesn't use the typical dhcpcd client

Thanks

Update:

Well after looking at this closely, discovered the problem is not with DNS entries, but setting the default GW. The thing is that dhcpcd sees the default gw and via hooks script in /system/etc/dhcpcd/dhcpcd-hooks runs setprop.

Also looking at logcat i can see that it picks up the right default gw but still isn't setting it:

V/WifiStateTracker( 106): IP configuration: ipaddr 192.168.1.74 gateway 192.168.1.254 netmask 255.255.255.0 dns1 192.168.1.3 dns2 192.168.1.254 DHCP server 192.168.1.3 lease 86400 seconds

but no default gw is listed when i run 'ip route show'... The other crazy thing is, that my dhcp server sends extra static routes, and these show fine... even work as expected.

If i manually add the route it works fine.... Well... i am a Linux admin but my first real attempt at working on Android, so still learning my way around... I am guessing setprop is used my Android to set the route (and other settings) but haven't figured out why it has failed. Will look some more, any help would be appreciated.
20th February 2010, 12:18 AM |#2  
OP Junior Member
London
Thanks Meter: 0
 
More
Well i finally got it working.... Posting here so that it might help others.

Basically the additional static routes were causing the problem. As i mentioned before, they were being added but no default GW. I removed the static routes from my dnsmasq config and hey presto the default gw was added.

Since i need these static routes for other boxes on my network, leaving left out was not really an option. So as a "band aid fix it" i added the default gw to the static routes list... So the line in dnsmasq looks like:

dhcp-option=121,<network>,<route>,0/0,192.168.1.254

This works.. but i don't really like it.

It seems that the static routes take precedence over the default gateway. I am not sure if this is a general problem or dnsmasq specific... Would be very suprised if it was dnsmasq only. Will open a bugreport and see what devs have to say
22nd October 2010, 08:42 AM |#3  
Member
Thanks Meter: 9
 
More
Hi,

we had the same problem with windows server 2008 and all android phones.
Make sure you have the static routes you want but also add a static route for 0.0.0.0/0 in your dhcp server. This way your android will work again.

good luck
19th March 2012, 07:42 AM |#4  
Junior Member
Flag Palmerston North
Thanks Meter: 5
 
More
Quote:
Originally Posted by yasn77

Well i finally got it working.... Posting here so that it might help others.

Basically the additional static routes were causing the problem. As i mentioned before, they were being added but no default GW. I removed the static routes from my dnsmasq config and hey presto the default gw was added.

Since i need these static routes for other boxes on my network, leaving left out was not really an option. So as a "band aid fix it" i added the default gw to the static routes list... So the line in dnsmasq looks like:

dhcp-option=121,<network>,<route>,0/0,192.168.1.254

This works.. but i don't really like it.

It seems that the static routes take precedence over the default gateway. I am not sure if this is a general problem or dnsmasq specific... Would be very suprised if it was dnsmasq only. Will open a bugreport and see what devs have to say

This problem was driving me nuts also. Turns out that dhcpcd is just following the spec (RFC3442)!

The problem is masked on some Androids because something else (probably a hook script) is reading option 3 ("router") and setting the default route. In fact, in this situation, option 3 will override the 0.0.0.0/0 route in option 121, which is a direct violation of RFC3442 (which states that the Router option MUST be ignored in the presence of the Classless Static Routes option).
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes