Detailed explanation of the role and location of the Hosts file

  

The mapping between the domain name and the IP address is specified in the Hosts file. If a domain name specifies an IP address in the hosts file, the system will not resolve its IP address through the DNS (Domain Name System) when accessing the domain name. Address, but directly access the specified IP address. In other words, with the help of the hosts file, we can bypass the DNS server and directly access some domain names.

In the case of Windows, the format of the Hosts file is <;<IP address> <domain name> <#comment>”, for example:

127.0.0.1 google .com # redirect google.com to 127.0.0.1

The following is the location of the hosts file in the common operating system:

1.Windows:%SystemRoot%\\system32\\drivers\\etc \\, such as C:\\Windows\\System32\\drivers\\etc\\2.Macintosh and iOS: /etc/hosts3.Symbian: C:\\system\\data\\hosts (Symbian OS 6.1– 9.0) and C:\\private\\10000882 \\hosts (Symbian OS 9.1+) 4.Android: /system/etc/hosts

Hosts files can be used for policing, such as blocking certain websites and setting their IP addresses to non-existent addresses; Or domain name hijacking, some virus programs will modify the hosts file, turn a domain name to a malicious website, and so on. The folder where hosts is located: Windows system hosts are located at C:\\Windows\\System32\\drivers\\etc\\hosts Android (Android) system hosts are located at /system/etc/hosts Mac (Apple) system hosts are located in the same way as Linux /etc/hosts iPhone (iOS) System hosts are located in /etc/hosts like Linux Mac. Linux system hosts are located in /etc/hosts. You can also convert text encoding and line break formats yourself using Notepad++. Of course, the old D share is converted. The method that takes effect after modifying the host: Windows Start->Run->Enter cmd-> Enter
Copy code
in the CMD window as follows: ipconfig /flushdns Linux terminal input
Copy the code
The code is as follows: sudo rcnscd restart For the systemd distribution, use the command
Copy the code
The code is as follows: sudo systemctl restart NetworkManager If you don't understand, please try the Mac OS X terminal input
Copy Code
The code is as follows: sudo killall -HUP mDNSResponder Android Open Flight Mode-> Turn off Airplane Mode General Method to Unplug Network Cable (Disconnected Network) -> Plug Network Cable (Reconnect Network) (Sometimes You don't need to do this anymore, anyway, the old D rarely refreshes the DNS, and the refresh can be parsed faster)

Copyright © Windows knowledge All Rights Reserved