Use the Windows Hosts file

Source: Internet
Author: User
    • Ad Blocking


No translation is performed here.


The hosts file uses a local database so that the local computer can also have the domain name resolution function. The host file is stored in the \ windows \ system32 \ drivers \ ect folder on the system disk. The name is hosts. The hosts file used by the local computer is much smaller than that used by the DNS server. When the local computer is used in a local network for the first time, the hosts file will be restored. However, this file is recommended for many websites. It can accelerate the access speed of web pages and help block advertisements and malware.


Make the hosts file a text file without a file name. Generally, the hosts file or hosts. Sam. "Sam" file appears on the machine, which represents a sample file. The hosts file or the hosts. Sam file can be opened with notepad, which is generally as follows:

---------------------------------------------------------------------------- # Copyright (c) 1993-2009 Microsoft Corp.
# This is a sample hosts file used by Microsoft TCP/IP for Windows.
# This file contains the Mappings of IP addresses to host names. Each
# Entry shoshould be kept on an individual line. The IP address shold
# Be placed in the first column followed by the corresponding host name.
# The IP address and the host name shocould be separated by at least one
# Space.
# Additionally, comments (such as these) may be inserted on individual
# Lines or following the machine name denoted by a' # 'symbol.
# For example:
# # source server
# # X client host
# Localhost name resolution is handled within DNS itself.
# localhost
#: 1 localhost


The content is generally like this.

If a computer has a hosts file, any process that uses the Windows TCP/IP stack will automatically search for it first. This search process is performed between trying to find the DNS server. Therefore, a single hosts error may cause an error message.


Accelerated browsing

Many so-called web accelerators use hosts files. In this way, you can resolve an IP address locally without using the DNS server, which saves some time.

But there are also some restrictions. The most obvious limit is the file size limit. Only a small portion of registered network addresses can be saved in this host file. This is useful for accelerating homepage browsing or common web pages. However, most web pages still require DNS servers. Note that when the hosts file is larger than kb, it will actually speed up browsing, unless the DNS Client service is set to manual startup mode.

Another restriction is that the IP address may change the number of IP addresses. In this case, you also need to update the corresponding hosts record.


Ad Blocking

This may be the biggest application to the hosts file. You can assign the loopback IP address to a URL. For example, will be immediately sent back to the local computer.

When we access the webpage, some advertisement images and other things will be automatically downloaded. These things do not come from the website you visit. If you want to block these advertising images and other things, you can right-click them to find the root cause of the image. These are used by the advertising department of Adobe Flash.


By adding the URLs of these ads to the local hosts file, you can block a large number of ads.


The same is true.

Related Article

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: 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.