質問

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.

役に立ちましたか?

解決 4

As Chris states, you can edit the host file of an emulator since it's already rooted.

http://www.bradcurtis.com/hosts-files-and-the-google-android-emulator/

他のヒント

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

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.

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.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top