hosts文件是一个计算机上存储IP地址和域名对应关系的文件。当计算机向一个域名请求时,会首先检查本地hosts文件,以确定域名对应的IP地址,提高解析速度。
在Window10中,前往C:WindowsSystem32driversetc路径,在该文件夹中可以找到hosts文件。双击hosts文件可以用记事本等文本编辑器打开。
在hosts文件中可以添加IP地址和域名。例如:192.168.0.1 example.com。在这个例子中,192.168.0.1是对应example.com的IP地址。
可以用#号注释掉一行,不会被计算机识别。例如:#127.0.0.1 localhost。
对hosts文件进行修改后,需要保存并保证没有后缀名。在记事本中保存时,可以选择“所有文件”并命名为“hosts”。保存完毕后,需要将hosts文件重启计算机后方能生效。
可以在命令行中输入ping example.com来测试hosts文件是否生效。
The hosts file is a file that stores the relationship between IP addresses and domain names on a computer. When a computer makes a request to a domain name, it will first check the local hosts file to determine the corresponding IP address, thereby improving the resolution speed.
In Windows 10, go to the C:WindowsSystem32driversetc path, where you can find the hosts file in this folder. Double-click the hosts file to open it with a text editor like Notepad.
You can add an IP address and domain name to the hosts file. For example: 192.168.0.1 example.com. In this example, 192.168.0.1 is the IP address corresponding to example.com.
You can use the # sign to comment out a line, which will not be recognized by the computer. For example: #127.0.0.1 localhost.
After modifying the hosts file, you need to save it and make sure it has no file extension. When saving in Notepad, you can choose "All Files" and name it "hosts". After saving, you need to restart the computer for the hosts file to take effect.
You can enter "ping example.com" in the command line to test whether the hosts file is effective.
网友留言: