Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Emulate hosts file on non-rooted Android

Is there a way to emulate the behaviour of a hosts file on non-rooted Android?

I need to test a website on Android. I get to the website via IP address but it seems to redirect to a URL that is not available from the phone. So is there a way to emulate hosts file behaviour to map this URL to the correct IP address.

From search I have found that the real hosts file is editable with a rooted device but that isn't currently an option for me.

like image 670
anotheruser1488182 Avatar asked Oct 15 '13 10:10

anotheruser1488182


2 Answers

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

like image 77
Yevgen Kulik Avatar answered Oct 11 '22 14:10

Yevgen Kulik


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.

like image 20
dagezi Avatar answered Oct 11 '22 15:10

dagezi