6

It was noted in another thread that it should be possible to build up a white list for an android device using the /etc/hosts file. I would like to experiment with this idea. Does anyone have any guidance to offer as to how to go about it?

It has been many years since I played with that area of networking, but from what I remember the host file allows you to specify an IP for an URL which overrides the published DNS settings. With that it is fairly easy to build a list of content that I want to have accessible, or explicitly blocked, but I am not sure how that helps prevent access to other content. I am not aware of, and so far google has not showed me, any way to tell the host file to intercept all other requests. Does android support some form of wild card in the hosts file? Or is there some way to disable DNS regardless of the active network connection?

Should note that the devices I am worried about at the moment are wi-fi only tables running android 2.3.3. I am willing to root them if necessary.

4 Answers 4

5

/etc/hosts doesn't allow wildcards (see here: https://serverfault.com/questions/118378/in-my-etc-hosts-file-on-linux-osx-how-do-i-do-a-wildcard-subdomain).

Two more links about /etc/hosts:

4

/etc/hosts is in this context is really only good for blacklisting.

For whitelisting, you'd be best off using a proxy server and then setting your device to use it in your device's network settings.

You can subscribe to an existing proxy server service, or set up your own at home. That should be enough info to get you googling to the answers you need. I've added a little more detail to this answer on your original thread.

FYI, using a proxy server does not require rooting.

3

The hosts file acts sort of like a local DNS, it will check the hosts file for the domain and see if there is an assigned IP address in it. If there is, that is the IP address used for the domain. You can't set a white list, but you could do more of a black list. The file looks something like this:

somebaddomain.com 127.0.0.1
someotherdomain.com 127.0.0.1

this would make any request to either of those domains resolve to localhost. If the domain is not in the file, it will then hit the external DNS to attempt to get the IP address.

There is a catch to this, you will need root to modify the hosts file.

0

For my home network's WiFi connected hosts (I have 4 of them, 3 Windows 10, 1 Ubuntu Linux 19.10), I always set their preferred DNS server address to the IP address of my Cable Modem / WiFi router (192.168.0.1). I have set the WiFi router's internal DNS severs setting to the fastest DNS servers I can find, which are usually OpenDNS:

208 67 220 123

 - and - 

208 67 222 123

I've always gotten blazing fast results doing it this way, regardless of the make / model number and configuration of my Cable Modem / WiFi router.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .