php editor Baicao hosts file is a configuration file used to map domain names and IP addresses. Its function is to perform domain name resolution on the computer and convert the domain name into an IP address, thereby enabling access to the website or service. By modifying the hosts file, functions such as blocking ads, accelerating access, and blocking malicious websites can be achieved. In addition, the hosts file can also be used to set up development and test environments to facilitate pointing the domain name to the local IP for debugging. In short, the hosts file plays a very important role in network access and development.
#The main function of the Hosts file is to establish a correlation database between commonly used URL domain names and their corresponding IP addresses. When the user enters the URL that needs to be logged in in the browser, the system will automatically look for the corresponding IP address from the Hosts file. If it is found, the system will immediately open the corresponding web page; if it is not found, the system will submit the URL to the DNS domain name resolution server for IP address resolution. In this way, the Hosts file can improve web page access speed and reduce the load on the DNS server.
Note: The mapping configured in the Hosts file is static. If the computer on the network changes, please update the IP address in time, otherwise you will not be able to access it.
Due to CDN acceleration failure, some acceleration nodes have problems. In order to solve the problem of being unable to access certain websites, we can directly point to the access node of the domain name by filling in the real available server IP address and URL in the Hosts file, bypassing the problematic acceleration node. In this way, you can successfully access those websites.
For websites that are frequently visited, we can improve the domain name resolution speed by configuring the mapping relationship between domain names and IPs in Hosts. Due to the mapping relationship, when we enter the domain name, the computer can quickly resolve the IP without requesting the DNS server on the network.
For Lotus servers and some database servers, if you directly enter the IP address during access, you cannot access it. You can only access it by entering the server name. Then we configure the Hosts file so that we can connect smoothly by entering the server name.
Many times, website builders need to build the "soft environment" before uploading and debugging. But similar to the mail service, you need to use a domain name to assist debugging. In this case, you can point the local IP address to a "virtual domain name" to achieve the required effect without any cost.
There are many websites that install various plug-ins into your computer without the user’s consent. Some of them may be Trojan horses or Virus. For these websites, we can use Hosts to map the domain name of the website to the wrong IP or the IP of the local computer, so that there is no need to access it. In the WINDOWS system, it is agreed that 127.0.0.1 is the IP address of the local computer, and 0.0.0.0 is the wrong IP address. If we write the following content in Hosts: 127.0.0.1 The domain name of website A to be blocked 0.0.0.0 The domain name of website B to be blocked In this way, when the computer resolves domain names A and B, it will resolve to the local IP or error IP, achieving the purpose of blocking websites A and B.
In the LAN of many units, there will be servers available for users to use. However, since DNS servers are rarely set up in local area networks, when accessing these servers, you have to enter IP addresses that are difficult to remember. This is quite troublesome for many people. You can give these servers names that are easy to remember, and then establish IP mapping in Hosts, so that when you visit in the future, you only need to enter the name of the server.
The above is the detailed content of What is the use of hosts. For more information, please follow other related articles on the PHP Chinese website!