The files Hosts of an operating system serve to be able to manage the web pages that are visited habitually copying the resolution between the URL and the DNS so that a URL is automatically associated with an IP address and thus avoids the communication with the corresponding DNS server . This can help us, for example, to block certain web pages by redirecting your URL to localhost or automatically translate some addresses by your IP in case the DNS is blocked.
There are several ways to edit the Android Hosts file:
- Use a text editor and do it directly on the smartphone.
- Copy the file to the computer and modify it by hand there (to apply filter lists, for example).
- Use programs designed to modify these entries.
All the above methods require the user to have root permissions on the device since this file is write-protected by the operating system itself.
In this tutorial we will use a program called Hosts Editor that allows us to modify the file directly from the device itself, make a backup of it and restore it whenever we want. We can download this application completely free from the Play Store.
Modify the Hosts file on Android
Once the application is downloaded, we execute it on our device and we will see a window similar to the following one.
The program may take more or less time to show the results according to the size of the current file. Once we show all the entries we can start to modify it.
First of all we can select one or more of the existing entries to eliminate them. We can also see more options by opening the application menu from the "Hosts Entries" tab.
From this menu we can:
- Search: Search for specific entries in the file (ideal for files with many entries)
- New Entry: Create a new entry in Hosts
- Toogle Selected: Mark the entries selected by the unselected ones.
- Delete Selected: Deletes selected entries from the file.
If we click on "New Entry" we will see a window similar to the following one.
Here we will see 2 sections. The first one is called "IP Address". In it we must enter the IP address to which the hosts that we will introduce in the box below will resolve. For example:
- IP Address: 173.194.34.247
- Host: www.google.es
In this way, when we write www.google.es we will automatically be redirected to the specified IP address (in this case, to the Google Spain website)
Backup copies of Hosts files
With this application we can also make backup copies of the domain files of the system to be able to restore them later or switch between them easily according to our needs. To do this we simply open the "Backups" tab and a list of the files we have copied will appear.
We select one of them and we can restore it or delete it according to our needs.
If you want to make a backup copy of the current file, simply open the menu, in the "Backups" tab and create a new copy in a few seconds.
In this way we will always have the domains of our system always controlled at all times being able to block certain pages or preventing others from passing through the DNS and traveling directly to the destination.