Emulate hosts file on non-rooted Android

You can run a DNS server on your Android device, if you don't want to mess with a desktop computer. I found one on the play store. It doesn't mention needing root or not, so probably it doesn't need root.

https://play.google.com/store/apps/details?id=com.icecoldapps.dnsserver

Basically you have to set your WIFI connections DNS server to 127.0.0.1 or localhost (Android allows that easily in the advanced details of a connection), and then use the app to set an IP for the host you want to alter.

That's it.


You can specify HTTP proxy on device's WiFi preference. On that proxy, you can hack HTTP, say modifying HTTP redirection response to redirect to your customised HTTP server. http://wiki.squid-cache.org/SquidFaq/ContentAdaptation looks informative.

Or keep redirection response and redirect the specified URL to your customised server.


1) You can use desktop as a source or internet for your device. And here you can use dnsmasq with some next rules (for ex. https://askubuntu.com/questions/53523/how-to-redirect-a-url-to-a-custom-ip-address) you need only share internet to device via usb.

2) you can setup on your device as dnsserver ip of your computer in that network. then same actions with dnsmasq