[Galaxy Ace S5830 Q&A, Help & Troubleshooting] d4eRc:
Hi there,

I'm using the following rom: [ROM[DEV]]AOSP GingerBread 2.3.7 [COOPER][V3][02-08-13]

Despite being a fast and stable rom, it suffers a bug on mobile data connection, whereas wifi works fine. I'm currently trying to fix that bug. I would have posted that bug report/analysis in the corresponding rom's thread, but I'm not allowed to due to the 10-posts-limit in the developmental sections.

The following sections show how the dns properties differ when using wifi or mobile data:

If you think "tl;dr", scroll down for my questions ;)

Connected to wifi:

# getprop | grep dns
[net.change]: [net.dnschange]
[net.dns1]: [192.168.1.25]
[net.dns2]: []
[net.dnschange]: [5]
[net.pdp0.dns1]: []
[net.pdp0.dns2]: []
[dhcp.wlan0.dns1]: [192.168.1.25]
[dhcp.wlan0.dns2]: []
[dhcp.wlan0.dns3]: []
[dhcp.wlan0.dns4]: []

As you can see:

wlan0 got its nameserver via dhcp

pdp0 (mobile data) has no nameserver set (because it's disconnected)

net1.dns got its value fr om dhcp.wlan0.dns1

-> internet access (name resolution) works

Now with wifi disconnected and mobile data connected:

# getprop | grep dns
[net.change]: [net.dnschange]
[net.dns1]: []
[net.dns2]: []
[net.dnschange]: [7]
[net.pdp0.dns1]: [139.7.30.126]
[net.pdp0.dns2]: [139.7.30.125]
[dhcp.wlan0.dns1]: []
[dhcp.wlan0.dns2]: []
[dhcp.wlan0.dns3]: []
[dhcp.wlan0.dns4]: []

wlan0 has no nameserver set (OK)

pdp0 (mobile data) has the right nameserver (Vodafone DE)

net1.dns has NOT copied its value from net.pdp0.dns1

-> internet access (name resolution) does NOT work

XDA member mahithm supplied a fix for that problem: http://xdaforums.com/showpost.php?p=48640501&postcount=133

He simply put a script to /system/etc/init.d/555dns that does the following:

#!/system/bin/sh
#Written By mahithm
setprop net.dns1 8.8.8.8
setprop net.dns2 8.8.4.4

initscripts are run once at boot, so this makes mobile data work as long as you were not connected to a wifi since the last boot. Connecting to wifi sets the dns server of the wifi and overwrites net.dns1. Disconnecting clears net.dns1, thus not allowing name resolution as without mahithm's fix.

I tried to modify /system/etc/dhcpcd/dhcpcd-hooks/20-dns.conf like this:

unset_dns_props()
{
for i in 1 2 3 4; do
setprop dhcp.${interface}.dns${i} ""
done
setprop net.dns1 8.8.8.8
setprop net.dns2 8.8.4.4
setprop net.dns3 $(getprop net.pdp0.dns1)
setprop net.dns4 $(getprop net.pdp0.dns2)
}

unset_dns_props() is calles when wifi is disconnected and dhcpcd (which is not needed for mobile data) quits. My modification should set the google dns to net.dns1/2 and try to extract the mobile data dns (if already set, only for testing purposes) to net.dns3/4. However, none of that works - it seems as if net.dnsX gets overwritten by another process after dhcpcd exits.

So now my questions are:

What service/program sets net.dnsX? Perhaps ConnectivityManager? How can I manipulate that behaviour?

May it be possible that what-service-soever tries to copy a wrong dns setting, e.g. from net.ppp0.dns1 which does not exists and thus is empty? Where are the communication interfaces set (build.prop etc.)?

Does dhcpcd (which calls the hook-script) not have permission to change net.dnsX but dhcp.*.dnsX?

Is there a possibility to create a hook that always gets called when net.dnsX changes?

Any other idea to fix it? How do other roms do this?