Ok, this is a constantly asked question, how to change mobile network DNS. But in different Android version, you will get different method. So this is the reason I ask this.
I have already known a method for Android 4 and below. Now, I want to know how to change mobile network DNS on Android 5.0 Lollipop and up.
A clue:
ndc resolver setnetdns <netId> <domains> <dns1> <dns2>
Someone said I should use this command to change mobile network DNS in Lollipop and up, but what is netId
? Where can I find this value? Could you give me an example?
I am not C/C++ programer, but I try to read relative source code, found netid
will be transform to unsigned long type by strtoul
function. So I guess netid
should be a hexadecimal string. I try using netcfg
output value, but it doesn't work.
Could you give me more explanation about this method? How to use it? Or is there any other effective method to change mobile network DNS in Lollipop and up?
netId
value from the CLI. I'm getting it through a Java method.