I've a website running on my computer, and I want to test it from my Nexus 7 tablet. I.e. over the local WiFi LAN. If I type in the IP address it connects, but shows the wrong web site, because I'm using named virtual hosting.
So, what I want to do is be able to type mysite.local
in to Chrome/Firefox on the Nexus, have them convert that to 10.1.2.3
(or whatever the local IP address is), then call the 10.1.2.3
server giving mysite.local
as the Host to request.
My Question: Does an Android 4.x tablet have an /etc/hosts
files, or equivalent, that I can edit? (Without having to root the tablet, or anything like that.)
On my Linux computers I do this by adding an entry in /etc/hosts
:
10.1.2.3 mysite.local
(Or Windows\System32\drivers\etc\hosts
on a Windows machine does the same.)
BTW, this is a semi-duplicate of Manually set a hostname for IP address (i.e. /etc/hosts equiv.?), but that question was for Android 2.2, where apparently it was not possible. (One of the alternative ideas suggested there was configure DNS at the local router, but as far as I can tell my router does not do DNS locally so does not have that option. I could set up my own DNS server to do this, but that feels like a Big Job Solution.)
Answer
You cannot simply edit the hosts file on Android, as it resides on a read-only file system: /system/etc/hosts
, see:
Alternatives are:
- use a DNS server like DNSMasq in your local network to take care for that "centrally"
- use "root powers" to force-edit the system file as described above
- install a "local DNS server" on your Android device to use that, e.g. DNS Server
No comments:
Post a Comment