Problem with getting DHCP lease from dnsmasq - Android Software/Hacking General [Developers Only]

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.

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

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

yasn77 said:
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
Click to expand...
Click to collapse
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).

Related

How to set DNS while using static IP over WiFi

I'm connecting with my HTC S710 to a WiFi with a static IP. The WiFi connection is set, I can ping other devices within the network but I can't view web pages and synchronize mails. I did lot of tests and I found that the problem is DNS! When I use IP address instead of www.something.com I can view the WWW site!
Does anybody know how to set DNS in my smartphone? DNS address is the same as gateway's in my case.
There's no possibility. Either you activate DHCP on your WiFi Gateway or you use a third party software that allows you to define WiFi profiles.
Does this one work for you? http://www.freewarepocketpc.net/ppc-download-wifi-profiles-v0-0-2.html (although it is originally designed for PPCs)
Hallo fwmone,
thanks for your post!
I have just installed the Wifi Profile program but it's for PPC so there are problems with filling in the right values. I hope I'll be able to figure out how to use it. Anyway the programmer is also Czech so I've wrote him an email asking whether he plans to build Smartphone version..
The wifi I connect to is a local provider and unfortunately he uses static IPs
I'm really surprised that Vox doesn't have such a simple thing like DNS manual settings.
Yeah, the static IP functionality is quite useless without the possibility to set a DNS server.
Means "local provider" you're using some type of wireless internet at home or is it at a location where you can't control the situation? As long as you're using the service at home, you might install a WAP that works as a repeater for the WAN and offers DHCP functionality.
Hi fwmone!
So the problem is solved! The application WiFi Profiles v0.0.5 helped. Despite it's for PPCs it is possible to use it and to set all network configuration including DNS. After applying the profile the connection works fine! GREAT!!
Thanks for your hint!
FYI: that local provider covers our street and I don't control the router/access point. But you're right WAP repeater would be also a solution.
Nice that it worked!

Captivate Wifi/3G data issue

Has anyone had a problem with the Captivate when in both WIFI and 3G coverage the phone will not download or open a webpage? If I shut off one or the other it works but if both are active it hangs up and doesnt download.
Is this by chance on an enterprise wifi access point? Such as one of those expensive cisco APs you find in schools and enterprise class networks? If so, there is currently a driver problem with the captivate connecting to it, but not trasnfering data. Whether the netwrok is encrypted or open doesnt seems to matter. Personally, I find this a bigger problem than the GPS issue. I had to use wifi static to manually set IP, subnet, etc. This is a workaround, not a fix.
jhannaman82 said:
Is this by chance on an enterprise wifi access point? Such as one of those expensive cisco APs you find in schools and enterprise class networks? If so, there is currently a driver problem with the captivate connecting to it, but not trasnfering data. Whether the netwrok is encrypted or open doesnt seems to matter. Personally, I find this a bigger problem than the GPS issue. I had to use wifi static to manually set IP, subnet, etc. This is a workaround, not a fix.
Click to expand...
Click to collapse
Hey, I think I'm running into this issue at my workplace (we definitely use those Cisco APs, I see them all around). I'm connected, I have an IP, but I can't browse anywhere.
Here's the weird thing though: I can connect to the company's wifi in any other building (I guess different APs?) than the one I'm in and wifi works fine. It's just the building my cubicle's in that doesn't work and it's infuriating!
well thats dumb.
I had that happen once since I bought the phone on launch. I restarted my phone and it went away.
I've had this problem as well, usually my phone switches to only wifi pretty quickly though, so I don't notice much. The phone acts like it is using the 3G connection because the arrows are both indicating data coming and going, but nothing actually happens unless only one or the other is on.
i need to check this at more places but at home i have a standard dlink dl-624 router with no security over comcast. i think my issue initially was because of the wifi sleep policy (see below) but now i am just getting really really slow speeds. pages seem to load slower than 3G....(i mean really cinemaxHD is showing last of the mohicans in pan and scan)....also the pages time out very very frequently.....
Anyone having problems check out the advanced setting for wifi. The phone has a WIFI sleep policy. my default setting was to disconnect from wifi after the screen locks. my screen locks after 30 seconds. so basically it always looking for my network. you can change it to never.
I want to reiterate our findings again. There are multiple threads on other forums concerning this as well. When it comes to wifi, the captivate has a major problem. DHCP does not work on enterprise networks. Period. It is a driver issue. The network can be open or using any form of encryption, the results are thr same. I had numerous software, hardware and network analyst tackling this issue all week in my department. It is related in part to most enterprise networks not using a default subnet mask of 255.255.255.0. There is a workaround, but it is not a fix. You can either set a static from your static pool of ip's in wifi settings, or, if u connect to multiple networks, use wifi static from the market to remember and apply seperate static configs accross multiple networks which is what were having to do currently. This affects all captivates, one which we consider a major problem with deploying this phone to our other users.
Sent from my SAMSUNG-SGH-I897 using XDA App
I had the same problem and this is how a turn around the problem when I'm connected but cannot browse.
-Use Wifi Static
- DNS from google 8.8.8.8,8.8.4.4
- switch to airplane mode
- activate wifi
- test my conection (open the browser and surf)
- switch to phone mode
Hope it help
floppy__ said:
I had the same problem and this is how a turn around the problem when I'm connected but cannot browse.
-Use Wifi Static
- DNS from google 8.8.8.8,8.8.4.4
- switch to airplane mode
- activate wifi
- test my conection (open the browser and surf)
- switch to phone mode
Hope it help
Click to expand...
Click to collapse
Did this, Wifi Static was being used previously to bypass dhcp, and it correctly assigned the IP settings, used the static I assigned from our static pool of addresses. Still no data transfer over Cisco APs at work.
jhannaman82 said:
Did this, Wifi Static was being used previously to bypass dhcp, and it correctly assigned the IP settings, used the static I assigned from our static pool of addresses. Still no data transfer over Cisco APs at work.
Click to expand...
Click to collapse
are you able to access a website thru his IP address? in this case it's a DNS problem, try the Google DNS 8.8.8.8 - 8.8.4.4
floppy__ said:
are you able to access a website thru his IP address? in this case it's a DNS problem, try the Google DNS 8.8.8.8 - 8.8.4.4
Click to expand...
Click to collapse
Its hit or miss really, seems the wifi radio stack locks up and stops responding according to our trace logs. yes i have tried both our internal DNS server's as well as googles. Everywhere else works perfectly. But at work with our Cisco open (no security) APs, it doesnt work most of the time. Through whos ip address??? I have a static set from our static pool to make sure dhcp was not the culprit. Its def the device, and not my netwrok. I have over 100 of these APs deployed here.
Wifi works great everywhere else (at home with WPA2, etc). There is def a problem with enterprise cisco APs.
Netmask issue and cisco AP's
Posted this over in development thread.
http://forum.xda-developers.com/showpost.php?p=7698066&postcount=410
Make sure your netmask is correct.
Thanks jhannaman82
I just wanted to give a big thanks to jhannaman82 for posting his company's findings with these wifi issues. My wifi works 100% at home on my linksys tomato router (of course, with a netmask 255.255.255.0). But on my college campus they use an enterprise router setup with 255.255.0.0 and I have been going NUTS trying to figure out if it is my captivate or the network.
I can sometimes get a few minutes of working connection, but it always seems to crap out within 1 or 2 minutes.
I will attempt to fiddle around with switching the dhcp to static IP, and will post my results. Thanks!
edit: no luck with static IP fiddling so far. from my laptop (connected wirelessly), I gathered that the netmask is actually 255.255.248.0... when I set my captivate's netmask to anything other than 255.255.0.0, it does not connect. It says "connected" when I set the netmask to 255.255.0.0, but as usual no data will transfer (it seems). I'm at a loss. *shrug* Hopefully there's a driver update or something.
Thanks jhannaman82!
I just wrote a script with the GScript app: "ifconfig eth0 netmask 255.255.255.0", and have a shortcut on homescreen. The problem was that the netmask was wrongly set to 255.255.0.0 on my office wifi. Now all I need to do is tap on this shortcut at office, and the connection works!
Has anyone contacted Samsung about this ?
I'm hoping this gets fixed soon... This refuses to stay connected at my school. Huge pain.
I entered in an IP address and 255.255.252.0 for my netmask after seeing what it was on my computer and turn on flight mode and tested the wifi and now it's working. I'm not sure if it's just one of those fluke connections that I get... but we'll see.

[Q] Looking for app to save ip profiles

Hello anyone know of an app that can save static ip profiles for the same ssid, for jellybean?
A complete profile manager would do too (one that controls sounds, and what not) just as long as I can specify a static ip profile for an ssid. Then be able to setup another profile for the same ssid using a different static ip.
bump, iv'e tried a ton of different apps but they wont save different profiles for same ssid.....
Most of them seem to be dhcp profile and a static profile. Allowing you to fast switch between the 2. I just need to setup up 2 static ip profiles for the same ssid. to fast switch static ip's when i need to.
Reasons being is I have a secondary router(in client mode, dhcp disabled) that passes through the main router ( like a switch ) which has dhcp enabled. Sure i can do the dhcp and static thing, but I hate having my ip change from time to time. I have apps that need static ip's that I use with the main router. and inside the main one I cant specify a static ip with dhcp on, and well I need dhcp running on that one. For other reasons. Sorry my setup is messed up but its how I need it.
Even if i could disable dhcp on teh main router and setup static ip for all my network devices, I still need an app to save 2 static ip's >,< for the same ssid. I may try to mod an app, but jesus thats a whole nother ball game.
He"double hockey sticks" I'll even take configuring advice at this point. Perhaps I can do something. But I'm pretty sure this is how I need it. If you need details just ask.
bother router have different isp connections. I frequently change between them both on numerous devices. It's a pain to keep chnaging ips around...
Any updates on this?
I am also interested for an app like this!

[Q] Bypassing Apt Complex WiFi Splash Page

Hello all,
I've recently moved to an apartment complex with very good community wifi. However, upon connecting to the wifi, I am redirected to a splash page where I input my apartment username/password. This is okay for my PC and android devices but not so good for my PS3, dvd player, and Google Chromecast. I've been looking for a way to bypass this splash page. I have a Linksys E1500 with DD-WRT installed that I think will be helpful in this endeavor. I've found a couple of options online such as:
1) Connect to wifi on PC, then connect PC to router, and activate internet connection sharing -> I tried this but it wasn't working. I wasn't sure what mode my router should be in (AP, client, bridge?) or what local connection to set it to; The instructions weren't clear. Also, I would like to have my own private network fed from the public network.
2) Use router as repeater -> I tried this as well but it didn't really work. I could get Google home page to load but then everything else would say "SSL connection error". I wasn't sure what to do at that point. Instructions were:
"Hard reset the router, then configure the router to 192.168.2.1 and mask 255.255.255.0. Next go to status/wireless and find the AP you want...and click join. When the screen changes to the wireless page, change the dropdown to 'repeater', add virtual interface with new SSID, hit save. Go to Security tab and uncheck everything under Block WAN, save, apply changes. Power cycle then go to basic router setup, assign WAN port to switch, enter opendns for your static DNS as follows
static dns 1 208.67.222.222
static dns 2 208.67.220.220
Then in services tab for dnsmasq put this line:
strict-order
hit save, apply settings again."
3) Use router with DD-WRT to create a tunnel through openVPN -> I didn't know how to configure this and couldn't find instructions.
4) Buy a travel router -> I want to save money so I would like to avoid this option if I can... People claim it works for their hotel splash pages but I don't know if it'll work with mine.
I might have done something wrong during my setup procedures; I can't say for sure. I would gladly try again if someone wants to walk me through the process/troubleshoot. My overall goal is to get my own network set up from the community network without having to deal with the splash page. I hope this is possible. If anyone knows another method I could try, let me know.
My apt complex specs are:
SSID: apartmentcomplex
Security type: none
IPv4: 192.168.1.156
Default Gateway: 192.168.1.1
DHCP Server: 192.168.1.1
Subnet Mask: 255.255.255.0
Splash page is: 192.168.1.1:8000
I appreciate the help.

One Plus 8 attacks my LAN VPN gateway...

This started a couple of days ago, and I have now mitigated it with a couple of firewall rules on the VPN gateway, as well as shutting down the dhcpcd server on that server (which I don't need anyway, and which probably should have been stopped long ago).
My LAN has a raspberry pi 4 running their debian firmware that is configured as a VPN gateway. It connects my LAN via ProtonVPN to the internet. This gateway is set up with a static IP address (192.168.2.49) on the LAN, and is configured to use another RPI on my LAN to get its DNS (192.168.2.50).
My one month old running OOS 11 OnePlus8 is rooted with magisk, and I have blocked most of the google stuff from the internet using afwall, and suspended non-essential system services using greenify. When connected to my LAN, the phone has a static IP address (192.168.2.71), has its gateway set to the VPN gateway (192.168.2.49), and its DNS to my local rpi DNS (192.168.2.50).
DHCP on my LAN is provided by my router (192.168.2.1).
WIFI on my LAN is provided by an enterprise-grade tp-link hotspot.
Starting a few days ago, for reasons mysterious, when the phone connects to the LAN, the VPN gateway would promptly go offline. Because I run it headless, I would be forced to reboot it - which made diagnosis a bit of a pain. Finally, I found a log entry on the VPN gateway that informed me that my OnePlus was trying to claim the ip address of the VPN gateway as its own (192.168.2.49) in spite of being set to use 192.168.2.71. This duplicate IP was causing dhcpcd on the VPN gateway to immediately take down its eth0 interface. This would break ALL connectivity because I have wifi on that RPI disabled.
Prior to this problem involving the OnePlus, that RPI had been up continuously for over 400 days, so it should certainly be considered to be reliable at the job it does and almost certainly the problem is with the OnePlus.
So, for some reason the OnePlus is trying to assert its assigned gateway address as its IP rather than the 192.168.2.71 that is set, at least in some packet that it uses to announce itself; once it is connected it works properly (which means the right IP address is being used).
I have deleted, then re-created the wifi connection profile and doing that did not cause the problem to go away.
I have another RPI VPN gateway on my IOT VLAN (192.168.24.0/24). No DHCP is available on the VLAN (a security measure), and I do have a profile for the phone that allows it to connect to the VLAN. It works without issue there, but then dhcpcd has been and remains shut down on that RPI. I suppose I could start dhcpcd on that server and see if the phone then breaks it too. I won't do this unless there is some merit to doing so...if it would help find the basic problem.
As I say, shutting down dhcpcd and blocking all dhcp traffic to/from the LAN VPN gateway mitigated the problem. But that the problem could occur at all says something is wrong, and I'm pretty sure it isn't a problem on my network.
This seems most likely to be a bug in OnePlus firmware, though why it would manifest after a month is a mystery to me. Does anyone have any insight? Or does anyone have any suggestions for another place on XDA where this post might more appropriately be placed?
I was pretty sure no one would have any idea about this. I have mitigated it by turning off dhcpcd on the VPN gateway and I am not inclined to do a deeper dive; I have too much else to do.

Categories

Resources