Domain Name System / Server is the one which takes care of translating the human readable domain names into machine understandable IP addresses. If you are not able to access a particular set of websites either from your laptop / phone, DNS server could be a reason for it. It happened to me recently that only few pages were getting loaded properly on my Nexus One. To fix the problem, one has to change the network configurations to use some of the popular DNS servers like Open DNS or Google’s public DNS. On Android phones, changing the DNS server is easy if you are using the static IP. You can do it from Settings > Wireless & network settings > Wi-Fi settings > Advanced (from menu) > check the ‘Use static IP’ option. After that, you will be able to change the DNS servers. However, when you are using dynamic IP (which will be the case most likely), the process is not straight forward. DNS server details will be taken from the DHCP server which assigns the IP.
Here are the steps to be followed to change the DNS servers:
- Your device should be rooted. Check out these instructions to root your device with a single-click.
- Download and install the latest Android SDK from here. This comes up with all the tools needed for development and testing of your application. Make sure the driver ‘ADB interface’ is installed on your machine. In most of the cases, the driver will be installed directly once you plug-in the device.
- Connect your Android device to your PC on debug mode. Enable USB debugging on your phone. Settings > Applications > Development > USB debugging.
- On your laptop, open a command prompt and enter “adb shell”.
- Use the commands “getprop dhcp.eth0.dns1” and “getprop dhcp.eth0.dns2” to know the DNS servers currently being used. There are applications like ‘ipconfig’ which will give you the same details.
- To change the DNS servers, use the command “setprop <property name>”. “setprop dhcp.eth0.dns1 208.67.222.222” “setprop dhcp.eth0.dns1 208.67.222.222”. This command has to be executed as root user.
- Remember, the above step will change the DNS servers only for the current session. You will have to repeat it when you are re-connecting to the network. Read through the next section to know about how to change the DNS server automatically when you re-connect to a network.
Changing the DNS servers automatically
- Android system chooses the DNS servers using the script located at “/system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf”
- By default, /system partition is mounted as read-only. Need to re-mount the same in read-write mode. Follow the instructions here to do this.
- Take a backup of the script. Download the modified version of the script from here. The modified script has two additional lines which will override the DNS server changes. The modified script uses the Google’s public DNS.
- Changes will be applied after restarting the connection / device.
Update: To change the DNS server of 3G connection, check out this article.
-- Varun
No comments:
Post a Comment