Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I was just curious to know what DNS server my phone used. So I launched a terminal emulator and I entered:

$ cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4

As you can see, my phone uses 8.8.8.8 and 8.8.4.4 as DNS servers (Google Public DNS servers).

At home (Wifi), my router is configured to give OpenDNS' servers through DHCP. But, on my phone, cat /etc/resolv.conf returns the same output. Same thing with 3G. And, even if I disable both Wifi and 3G, and then reboot the phone, it still uses Google's Public DNS servers.

I don't remember having changed resolv.conf or installed any application to change it.

My phone is an HTC Desire with CyanogenMod 7.2.0.1 (Android 2.3.7).

Can someone explain me why my phone uses Google Public DNS? Is it a common configuration for any Android devices, or CyanogenMod ROM?

share|improve this question

1 Answer 1

up vote 9 down vote accepted

According to Steve Kondik, this is essentially old code that is leftover from older versions of CyanogenMod:

This was only here for apps that were statically linked against uclibc in old CM versions. It can likely just be removed.

However, he also goes on to note:

Also, this file is NOT written when connecting to a network as /system is readonly. The actual DNS servers are read from system properties.

I also just verified that the DHCP supplied servers are actually being used, so this issue is invalid unless someone proves otherwise.

So the values in /etc/resolv.conf actually don't reflect your DNS settings. What you can do instead is use getprop to find your DNS values. You can pare it down rather nicely if you grep the output like so:

getprop | grep dns

Also worth noting: the /etc/resolv.conf file appears to have been removed completely in later versions of CyanogenMod. I don't have one on CM10 at all, but getprop does correctly show my DNS settings.

share|improve this answer
    
Great answser, thanks. However, getprop | grep dns doesn't return anything. getprop | grep -E '([0-9]{1,3}\.){3}[0-9]{1,3}' (looking for IPv4 address) doesn't return relevant result. Returned properties are ro.baseband, ro.build.description, ro.modversion and gsm.version.baseband. Any idea? –  Morgan Courbet Oct 23 '12 at 20:16
    
@Morgan: I suppose it might be some kind of difference between CM7 (you're running) and CM10 (what I tested on). What happens if you don't grep the output at all? Do you see anything relevant? (might want to pipe it into more or similar since it could be lengthy) –  eldarerathis Oct 23 '12 at 20:43
    
Now, I have relevant results: [dhcp.eth0.dns1]: [], [dhcp.eth0.dns2]: [], [dhcp.eth0.dns3]: [], [dhcp.eth0.dns4]: [], [net.dns1]: [192.168.10.110], [net.dns2]: [], [net.rmnet0.dns1]: [192.168.10.110], [net.rmnet0.dns2]: [0.0.0.0] , [net.dns1.3837]: []. Maybe my Internet connection was still disabled when I ran the command. Do you know which one is used? Do you recommend an application or a method to change it? –  Morgan Courbet Oct 24 '12 at 15:42
1  
@Morgan: I don't have a Gingerbread device onhand to test, but there should be a way to do it in the standard wireless settings if you configure a static IP (I don't think you can do it this way if you use DHCP, unfortunately). On JB I long-press the network I'm connected to and select "Modify" to get to it. It may be under the "Advanced setttings" though (menu button when on the list of wifi networks). You can also use setprop but it won't persist across reboots/disconnects. For example. setprop net.rmnet0.dns1 <your DNS IP> should change the value of the net.rmnet0.dns1 property. –  eldarerathis Oct 24 '12 at 15:49
1  
And I think the more specific one would be used by the adapter (net.rmnet0.dns1 in your case), though it may be inheriting that value from the more generic net.dns1 property. –  eldarerathis Oct 24 '12 at 15:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.