Change mobile network DNS on Lollipop and up 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 &lt;netId&gt; &lt;domains&gt; &lt;dns1&gt; &lt;dns2&gt;


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?
I don't use Lollipop on my phone anymore. However since your question is about Lollipop and up, and I use Marshmallow, I can confirm that:

ndc resolver setnetdns devname dnsdomain dns1 dns2


works. It appears that you do not need to know the network ID anymore in Marshmallow, and you only need the device name.

So for example:

ndc resolver setnetdns rndis0 "" 8.8.8.8 8.8.4.4


will set the DNS for the rndis0 interface to Google's public DNS servers.