How to change 3G dns setting on Android?

I want to change the 3G dns setting on an Android 2.1 device. I managed to install busybox on my device, I can also get dns info using adb shell getprop | grep dns adb shell getprop | grep dns . The only problem is that it shows me net.pdp0.dns1 and net.pdp0.dns2 , not net.rmnet0.dns1 and net.rmnet0.dns1 , so I cannot change the setting.

I know net.rmnet0.dns1 for a 3G connection, so what about net.pdp0.dns1 ? How can I upgrade to net.rmnet0.dns1 ?

thanks

+6
android
source share
2 answers

The Android DSN file is located in the following directory:

In android file system
System / etc / DHCPcd / DHCPcd hooks / 20-dns.conf

The 20-dns.conf file contains the dns configuration, you can change this file as follows:

 # Set net.<iface>.dnsN properties that contain the # DNS server addresses given by the DHCP server. set_dns_props() { case "${new_domain_name_servers}" in "") return 0;; esac count=1 for i in 1 2 3 4; do setprop dhcp.${interface}.dns${i} "" done count=1 for dnsaddr in ${new_domain_name_servers}; do setprop dhcp.${interface}.dns${count} ${dnsaddr} count=$(($count + 1)) done setprop dhcp.eth0.dns1 8.8.8.8 setprop dhcp.eth0.dns2 8.8.8.4 } unset_dns_props() { for i in 1 2 3 4; do setprop dhcp.${interface}.dns${i} "" done } case "${reason}" in BOUND|INFORM|REBIND|REBOOT|RENEW|TIMEOUT) set_dns_props;; EXPIRE|FAIL|IPV4LL|RELEASE|STOP) unset_dns_props;; esac 

(Note: please take a backup of the source file if you need a source file)

set your DNS in the next line

 setprop dhcp.eth0.dns1 8.8.8.8 setprop dhcp.eth0.dns2 8.8.8.4 
+1
source share

This can help if you specify the type of device you have. From what I read on the Internet, Samsung devices use the pdp0 interface names (perhaps this is exactly how Samsung relates to 3G connections). Personally, I use all HTC devices, and the 3G interface is always rmnet0.

Is your phone rooted? You may not be able to set properties in the "net" category without root privileges.

If you are root, have you tried "setprop net.pdp0.dns1"? Also, "adb shell getprop | grep dns" gives you "net.dns1"? I believe this is the default method Android searches for DNS servers. You can also set this property.

You can check if it works when running nslookup, it will show you the server it is requesting to.

Good luck, B-Rad

0
source share

All Articles