简体   繁体   English

在非root用户的Android上模拟主机文件

[英]Emulate hosts file on non-rooted Android

Is there a way to emulate the behaviour of a hosts file on non-rooted Android? 有没有办法在非root用户的Android上模拟主机文件的行为?

I need to test a website on Android. 我需要在Android上测试一个网站。 I get to the website via IP address but it seems to redirect to a URL that is not available from the phone. 我通过IP地址访问该网站,但它似乎重定向到手机无法提供的URL。 So is there a way to emulate hosts file behaviour to map this URL to the correct IP address. 那么有没有办法模拟主机文件行为,以将此URL映射到正确的IP地址。

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. 从搜索中我发现真正的主机文件可以使用root设备进行编辑,但这对我来说当前不是一个选项。

1) You can use desktop as a source or internet for your device. 1)您可以将桌面用作设备的源或互联网。 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. 在这里你可以使用dnsmasq和一些下一个规则(例如https://askubuntu.com/questions/53523/how-to-redirect-a-url-to-a-custom-ip-address )你只需要分享互联网到设备通过USB。

2) you can setup on your device as dnsserver ip of your computer in that network. 2)您可以在您的设备上设置为该网络中计算机的dnsserver ip。 then same actions with dnsmasq 那么与dnsmasq相同的动作

You can run a DNS server on your Android device, if you don't want to mess with a desktop computer. 如果您不想弄乱台式计算机,可以在Android设备上运行DNS服务器。 I found one on the play store. 我在游戏商店找到了一个。 It doesn't mention needing root or not, so probably it doesn't need root. 它没有提到是否需要root,所以可能它不需要root。

https://play.google.com/store/apps/details?id=com.icecoldapps.dnsserver 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. 基本上,您必须将WIFI连接DNS服务器设置为127.0.0.1或localhost(Android允许在连接的高级详细信息中轻松实现),然后使用该应用程序为要更改的主机设置IP。

That's it. 而已。

You can specify HTTP proxy on device's WiFi preference. 您可以在设备的WiFi首选项上指定HTTP代理。 On that proxy, you can hack HTTP, say modifying HTTP redirection response to redirect to your customised HTTP server. 在该代理上,您可以破解HTTP,例如修改HTTP重定向响应以重定向到您的自定义HTTP服务器。 http://wiki.squid-cache.org/SquidFaq/ContentAdaptation looks informative. http://wiki.squid-cache.org/SquidFaq/ContentAdaptation看起来很有用。

Or keep redirection response and redirect the specified URL to your customised server. 或者保留重定向响应并将指定的URL重定向到自定义服务器。

As Chris states, you can edit the host file of an emulator since it's already rooted. 正如Chris所说,你可以编辑模拟器的主机文件,因为它已经被植根了。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android:在非根目录设备上运行脚本 - Android: run a script on non-rooted device Android : 使用非 root 的 android 设备捕获 HTTP 请求 - Android : Capturing HTTP Requests with non-rooted android device 非root用户设备上的Android用户空间文件系统驱动程序? - Android userspace filesystem driver on non-rooted device? 以编程方式在Android设备上创建Google帐户(非root用户设备) - Creating a google account on android programatically (non-rooted device) 外部指纹扫描仪,用于无根Android平板电脑 - External fingerprint scanner for non-rooted Android tablets 是否可以在非 root 的 android 手机上运行本机 arm 二进制文件? - Is it possible to run a native arm binary on a non-rooted android phone? 是否可以在非 root android 手机上添加属性? - Is it possible to add a property on a non-rooted android phone? 我们可以在 Android 上使用 'dpm set-owner' 用于有根/无根 Android 上的生产设备吗 - Can we use 'dpm set-owner' on Android for production devices on Rooted/Non-rooted Android 如何重新启动非root用户的设备? - how to restart a non-rooted device? 如何使用adb命令在非root用户的android设备中擦除用户应用,用户数据,用户缓存? - How to wipe user apps, user data, user cache in non-rooted android devices using adb commands?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM