On the web, we can get third-party applications that allow us to block access to certain pages, but these applications tend to have a disadvantage that if a user has programming knowledge, they can lift the protection that was configured and unblock the page , for Therefore, it is advisable to opt for a more classical option , modifying the host file found on the computer’s system.
This host file is consulted by the browser every time a user accesses a web page, it fulfills a similar function to DNS servers. That is why, if you want to block access to a web page, we will have to open the file and add the link to the page , in this article we will show you how to locate and modify it.
- Where can I find a hosts file to block web pages?
- On window, MAC and Linux
- Using Android or iOS
- What are the steps to modify a hosts file and save it correctly?
- On a Windows computer
- With a Linux operating system
- Using a MAC
- What are the advantages and disadvantages of using a hosts file?
- What is the correct way to protect a hosts file?
Where can I find a hosts file to block web pages?
Every operating system contains in its system files, a hosts file, with the same content, but located in a different way in the system, to find it we will do it as follows:
On window, MAC and Linux
If we use the Windows operating system:
- We head to the ‘Local Disco (C)’
- Click on the ‘Windows’ folder
- We will observe a variety of folders and files, we slide to the ‘System32’ folder.
- Inside it, we locate the ‘Drivers’ folder
- Click on the ‘etc’ folder and we will have access to the computer’s hosts file
In the case of the MAC:
- We access ‘Finder’ and press the keys ‘Cmd + Shift + G’
- In the window that will appear we write ‘/ etc’, click on ‘Go’
- It will redirect us to the directory, where the hosts file is located
- We can access with a file viewer, to be able to review the content
And on Linux system, the process is:
- We open a window in the terminal
- We write the following command to open the host file, along with a text editor: sudo nano / etc / hosts.
- We enter the name and password, and you can see the content of the hosts file.
Using Android or iOS
Unlike tabletop computers, not every type of cell phone brings with it the possibility of modifying these files, in fact, the computers that make use of the iOs system are not allowed to make these configurations, however, the computers that have With the Android system, if they can make these modifications, through a file reader application , which we will do as follows:
- We go to the application store, and download the application, Open Hosts Editor .
- Once downloaded, click on the application icon to activate it, in it we can modify the host, make a copy, or restore it.
What are the steps to modify a hosts file and save it correctly?
Modifying the content of this type of file such as domain names and IP, will be of help to us for any type of web task that we carry out, although, we must take into account that these modifications will only be for the computer on which it is being carried out. Depending on the operating system, we will:
On a Windows computer
To modify in this system, we do it from the administrator option, as follows:
- We go to Start, right-click on the ‘Notepad’ application.
- Click on the option ‘Open as Administrator’
- In the ‘File’ tab we will place the path: ‘C: \ Windows \ System32 \ Drivers \ etc’, we select to show us all the files that are found, we open the hosts file.
- We modify and add the content that is desired, in the case of web pages, we must write the link in the last part of the text (avoiding the #), before this, put the IP ‘127.0.0.1’.
- And we give it to save in the ‘File’ tab, so that the configuration takes effect.
With a Linux operating system
In a similar way to Windows, in this type of system we can modify the host file as a superuser, as follows:
- We write the code ‘I knew your’, in order to access this level, we write the user password.
- We type the path ‘/ etc / hosts, in the editor of our preference, for example, if a file editor will be used, the path would look like this:’ editor name / etc / hosts’
- We proceed to modify and save.
Using a MAC
In the same way as in the Linux system, we can access it through a path: sudo nano / private / etc / hosts /. The other alternative would be to open it with a file editor, thus leaving sudo name editor / private / etc / hosts, we modify it, and save.
What are the advantages and disadvantages of using a hosts file?
Despite the fact that at present these hosts files remain as specific tools for network administrators, due to the creation of DNS services, these files have the advantage:
- They prohibit access to the web pages, previously selected
- Authentication of the IP of website domains, to know if it is safe and not a fraud to steal information.
- Ease of editing
However, these files also have a disadvantage, with respect to their vulnerability , since they can be modified by external malicious programs, which may not be detected by the administrator and alter the IP with malicious links.
What is the correct way to protect a hosts file?
To avoid any invasion and unwanted alteration to the hosts file, specifically to the IP addresses of the domains, caused by a malicious program or some type of malware , the best option is to convert it into a read-only file , we can convert it in the following form:
- We go to the folder where the hosts file is located, we access it, right-click on the file.
- We click on ‘Properties’ and we convert it into a read-only file.