Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change 3g dns setting on Android?

Tags:

android

I want to change 3G dns setting on Android 2.1 device. I managed to install busybox on my device, i can also get dns information by using 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 can't change the setting.

I know that net.rmnet0.dns1 is for 3G connection, so what about net.pdp0.dns1? How can i change to net.rmnet0.dns1?

Thanks

like image 212
kuka Avatar asked Jan 06 '11 13:01

kuka


1 Answers

Android DSN file contains in following directory:

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

20-dns.conf file contains dns setting, you can modify this file by following way:

# 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 backup of origin file , if you need origin file)

set your dns in following line

setprop dhcp.eth0.dns1 8.8.8.8
setprop dhcp.eth0.dns2 8.8.8.4
like image 185
Mahesh Avatar answered Oct 06 '22 23:10

Mahesh