The role of the C:\WINDOWS\system32\drivers\etc\hosts file

Source: Internet
Author: User

Let's take a look at the original hosts file of the C:\WINDOWS\system32\drivers\etc\hosts system (not changed)

Open the original Hosts file to view the original content

Host is a system file without extension, can be opened with a tool such as Notepad, its role is to use some of the common URL domain name and its corresponding IP address to establish an association "database", when the user in the browser to enter a login URL, The system will first automatically look for the corresponding IP address from the Hosts file, once found, the system will immediately open the corresponding webpage, if not found, then the system will submit the URL to the DNS domain name resolution server for IP address resolution. Now I would like to introduce you to this document's three special magical.


Re-retrieve the "failed" url
The author is very ashamed of this, some days ago login several times Sohu site, can home is not open, so then knew Sohu may due to internal what adjustment and will server off, I even schadenfreude texting to friends to report their findings of "Breaking News"! When I know that in other almost all of the computer can open the legendary Sohu website and only I can't open, the author is silly, is really a friend said "character problem" ...
According to the general problem solving, enter "Ping www.sohu.com" in the Run box and find that the IP address returned is not the "220.181.26.133" corresponding to Sohu, but rather the "127.0.0.1". So the truth is, The original web page malicious script will be the author's Hosts file modified, that is, in the Hosts file added a "127.0.0.1www.sohu.com" record, when the author in the Address bar input Sohu URL, the system resolves the IP address is not correct " 220.181.26.133 "But" 127.0.0.1 ", so nature will not open.
The workaround is simple, locate the hosts file in the C:\windows\system32\drivers\etc folder and open it with Notepad (the Windows 9x/me system is looking in the C:\Windows folder) and record the error in it (such as " 127.0.0.1www.sohu.com ") or all records deleted, save the file exit, then login Sohu site should be unimpeded.
Tip: If the user feels manually looking for the hosts file and manually specifying the Notepad tool to open the Hosts file
Automatically block Web page malicious plugin
Online watch Free TV drama is the author of a great hobby, the previous period of time by a hero friend recommendation, the author finally found a very good free online movie site, but in the opening of each movie play page before, Site will dan out a request to install Baidu Toolbar page and no user consent to immediately enter the download and installation status! Although this page window can be a close, but to see the movie is not a, every time to connect to the download will certainly affect the normal Web page opening speed and the flow of the video is playing.
Through observation, in each movie play page Dan out of this Baidu Toolbar installation window is the same URL, because the original URL is longer, we use Http://www.123.com/aa.exe instead, below we open the System folder hosts file, in the file opened a new line, enter "0.0.0.0http://www.123.com/aa.exe" (the input does not have quotation marks, but there is a space between the IP address and the URL), then save the file and exit when the movie site tries to open http://www.123.com/ Aa.exe the page, the system automatically resolves it to an impossible IP address such as "0.0.0.0", which also blocks the Web plugin.
Tip: 1. Users can use the same method to add other malicious plug-ins, a variety of Web page Dan ads and some illegal sites added to the Hosts file for a thorough screening. In addition, if the user needs to add a block URL to the hosts file frequently, you can also not need to go to the system directory every time to find the Hosts file: the same will "Yahoo Assistant" switch to the "Edit Hosts Table" tab, click the "Add" button, so you can batch to the Hosts file to add a blocking URL.
2. Have you ever experienced such a strange thing: in the normal browsing of the Web or other office operations, IE will automatically every once in a while, Dan out of the full screen of Web ads and these Web ads content will be automatically randomly transformed! But the format of the URL is relatively fixed: such as Http://www.xxx.net, http://www.xxx.net/v/and http://www.xxx.net/new/, in fact, this is a similar "Win32.Troj.PopWeb" Series of Trojan virus, you can also follow the above method to resolve these URLs to "0.0.0.0", so as to get rid of the virus harassment.
One-click Login LAN designated Server
Unit "senior Engineer" in the company's local area network built a CS battle server, so we one of those who eat full family are full of bachelors will have a good place in the off-hours recreation. However, there is a drawback, LAN does not set up a DNS server, so we can only enter the IP address at a time to log in, although only a number of not a lot of numbers, but after all, the number is boring Ah!
In this case, we can modify the hosts file to achieve one-click Login LAN CS Server for the purpose: Open the Hosts file, also in the newly opened blank line entered "221.555.78.122 aa.com" ( Assume that 221.555.78.122 is the CS server in the LAN IP address), so that we just enter "aa.com" can be directly logged into the LAN CS server.

Originally from: http://apps.hi.baidu.com/share/detail/5250759

Under Windows 98 system, the file is in the Windows directory, which is located in the C:\WINNT\SYSTEM32\DRIVERS\ETC directory on the Windows 2000/XP system. The file is actually a plain text file that can be opened with ordinary text editing software such as Notepad.
Open the Hosts file with Notepad, first see Microsoft's description of this file. This file is based on the TCP/IP for Windows Standard, its role is to include the IP address and host name (hostname) mapping, is a mapping IP address and host name (hostname) provisions, the requirement that each segment can only include a mapping relationship, The IP address should be placed at the front of each paragraph, and then the mapped host name (hostname) will be written on the space. For this section of the mapping instructions with "#" split after the text description.

Now let's look at how the hosts work in Windows.

We know that access to the Web site on the network, the first through the DNS server to resolve the network domain name (www.XXXX.com) to 61.xxx.xxx.xxx IP address, our computer can access. For each domain request we have to wait for the DNS server to return IP information, so that the efficiency of access to the network will be reduced, and the hosts file can improve the resolution efficiency. According to the Windows system, before a DNS request is made, the Windows system will first check if there is an address mapping relationship in its Hosts file, and if so, call this IP address mapping if no domain name resolution is presented to the known DNS server. This means that the hosts request level is higher than DNS.


Knowing how the Hosts file works, what does it do in specific use?
1, speed up the domain name resolution

For sites that you want to visit frequently, we can configure the domain name and IP mappings in the hosts so that when we enter the domain name computer We can quickly resolve the IP without having to request a DNS server on the network.

2. Convenient for local area network users

In many units of the local area network, there will be servers available to users. However, because the LAN generally rarely set up a DNS server, access to these services to enter the hard-to-remember IP address, for many people is quite troublesome. It is now possible to give these servers an easy-to-remember name, and then set up an IP map in the hosts so that we can enter the name of the server when we access it later.

3. Blocking Websites

Now there are many websites without user consent to install a variety of plug-ins to your computer, some may be Trojan or virus. For these sites we can use the hosts to map the site's domain name to the wrong IP or the IP of its own computer, so that it does not have access. We wrote the following in the hosts:

127.0.0.1 #屏蔽的网站
0.0.0.0 #屏蔽的网站

In this way, the computer resolves the domain name to native or wrong IP, and achieves the purpose of shielding.

4. Smooth Connection System

For Lotus servers and some database servers, if you enter the IP address directly when you access that is inaccessible, you can only enter the server name to access. Then we configure the hosts file so that the input server name can be successfully connected.

Finally, the mapping of the Hosts file configuration is static, and if the computer on the network changes, update the IP address in a timely manner, otherwise you will not be able to access it.

Its role:
is to map IP and URLs. Access to the site must be through the DNS server to resolve the domain name to an IP address, so that the browser can know where to connect to the site we want, if each domain name request to wait for the DNS server to return the IP address, it will reduce the efficiency of network access. To improve access efficiency,

In the processing logic of windows, it always finds the correspondence between the domain name and the IP in the hosts file.

If the corresponding relationship exists, Windows connects directly to the IP address described in the hosts table, and only sends a request to the DNS server to resolve the domain name when it is not found, which is somewhat convenient for the user, because the hosts table has a higher priority than any DNS server. We can use it to skip the domain name resolution this step, the speed of access to the site can be improved, but also not afraid of the DNS server failure when the day should not be called the ground is not, LAN users can also use their own domain name set by the hosts table to access the network section of a machine provided by the site, without the memory complex IP;

Because of the priority of the hosts table, it can also be used to block malicious sites.
When there is IP in DNS can not be resolved, but also directly in the hosts table to join, you can access the site, or enter the domain name no response.

The role of the C:\WINDOWS\system32\drivers\etc\hosts file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.