How to change mobile connections's DNS on Android KitKat? I want to avoid censorship from my local mobile ISP (it blocks imgur, for example, for some unknown reason. 


Screenshot (click image for larger variant)

I'm pretty certain that I can circumvent this by changing my DNS to Google DNS or OpenDNS, but I'm not really sure how to accomplish this on KitKat.

Info:
Device: Nexus 5
Android version: 4.4.2
Device status: rooted
Ok, first of all full disclosure: I'm the author of an app which is now on the Google Play Store and which makes you able to change DNS for any mobile connection on Android 4.4. The app requires root, costs a couple of bucks and is called Override DNS.
I was told, on a now deleted answer, that is fair to link to my app as long as I expose it clearly.

The problem I found with this release of Android (4.4) is that, apparently for caching reasons, the system behaviour has been changed to redirect all DNS queries to a system daemon called netd (here's a link to a presentation related to Android networking before 4.4 which, however, covers part of these topics).

The getprop/setprop method does not work anymore. Those values, when changed, get simply ignored by the netd daemon.

It's necessary to communicate directly to the daemon via the /dev/socket/netd socket. In Android it's now present a tool called ndc which does exactly this job.

The syntax for the DNS related stuff is this:

# ndc resolver flushif &lt;iface&gt;
# ndc resolver flushdefaultif
# ndc resolver setifdns &lt;iface&gt; &lt;domains&gt; &lt;dns1&gt; &lt;dns2&gt;
# ndc resolver setdefaultif &lt;iface&gt;


The app automatically guesses the network device name and applies these commands each time a mobile network gets activated.