SoFunction
Updated on 2025-04-11

About Hosts Files

Many users know that there is a Hosts file (without a suffix) in the Window system. In Windows 98 system, the file is in the Windows directory and in the C:\Winnt\System32\Drivers\Etc directory in the Windows 2000/XP system. This file is actually a plain text file that can be opened with ordinary text editing software such as Notepad.

When I opened the hosts file with notepad, I first saw Microsoft's instructions on this file. This file works according to the TCP/IP for Windows standards. Its function is to include the mapping relationship between IP address and Host name (host name). It is a provision that maps IP address and Host name (host name). It requires that each segment can only include one mapping relationship. The IP address must be placed at the front of each segment, and then the mapped Host name (host name) is written after a space. The mapping instructions for this paragraph are divided by "#" and then explained in text.

Now let's see how Hosts works in Windows.

We know that when accessing a website on the Internet, we must first resolve the network domain name () into an IP address through the DNS server before our computer can access it. If we wait for each domain name request to resolve and return IP information, the efficiency of accessing the network will be reduced, and the Hosts file can improve the parsing efficiency. According to the Windows system regulations, before making DNS requests, the Windows system will first check whether there is this address mapping relationship in its Hosts file. If so, call this IP address mapping. If not, domain name resolution will be proposed to the known DNS server. That is to say, the request level of Hosts is higher than that of DNS.

If you know how the Hosts file works, what are its functions in specific use?

1. Accelerate domain name resolution

For websites that you want to visit frequently, we can configure the mapping relationship between domain names and IPs in Hosts, so that when we enter the domain name, the computer can quickly resolve the IP without requesting the DNS server on the network.

2. Convenient LAN users

In many units' local area networks, there will be servers provided to users. However, since DNS servers are rarely set up in LANs, it is very troublesome for many people to access these services. Now we can give these servers an easy-to-remember name, and then establish an IP map in Hosts. In this way, we can just enter the name of this server when accessing in the future.

3. Block the website

Nowadays, many websites install various plug-ins on your computer without the user's consent, and some may be *s or viruses. For these websites, we can use Hosts to map the domain name of the website to the wrong IP or the IP of our computer, so that we don’t need to access it. For example, if you don’t want to visit, then we write the following content on Hosts:

127.0.0.1 #blocked website
0.0.0.0 #blocked website

In this way, the computer resolves the domain name to the local machine or the wrong IP, achieving the purpose of blocking.

4. Smoothly connect to the system

For Lotus servers and some database servers, if you enter the IP address directly during access, it is not accessible. You can only enter the server name to access it. Then we configure the Hosts file so that we can connect smoothly by entering the server name.

Finally, it should be pointed out that the mapping of the Hosts file configuration is static. If the computer on the network changes, please update the IP address in time, otherwise it will not be accessible.