Hosts native DNS domain name resolution let all domain Names "belong" to You

Source: Internet
Author: User

Intermediary transaction SEO diagnosis Taobao guest Cloud host technology Hall

As we all know, a domain name is registered to belong to someone else, other people want to explain how to resolve, we are unable to control, but some friends often ask me what is the domain name hijacking, what is the reverse analysis, which makes me feel that many people still do not understand the domain name is how to resolve. Through this article, you can easily realize such as Baidu's Web site can visit your own site, of course, this is just a simulation, designed to let everyone understand how the domain name analysis is going on, we do not do bad ah, hehe.

Location of the Hosts file

Many users know that there is a Hosts file (no suffix name) in the window system and that the file is in the Windows folder under Windows 98 system.

In the Windows 2000/XP system located in the \%systemroot%\system32\drivers\etc folder, where%Systemroot% refers to the system installation path. For example, when Windows XP is installed in C:\WINDOWS, the Hosts file is in C:\WINDOWS\system32\drivers\etc.

You can also search for hosts files using Windows's own lookup feature.

This file is actually a plain text file, with ordinary text editing software such as Notepad can be opened and edited.

Two. The basic content and grammar of the Hosts file

Use Notepad to open the Hosts file, you can see Microsoft's description of this document. The hosts document generally resembles the following basic content

# Copyright (c) 1993-1999 Microsoft Corp.

#

# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.

#

# This file contains the mappings's IP addresses to host names. each

# entry should is kept on a individual line. The IP address should

# is placed in the ' the ' followed by the corresponding host name.

# The IP address and the host name should is separated by at least one

# space.

#

# Additionally, comments (such as) may is inserted on individual

# lines or following the machine name denoted by a ' # ' symbol.

#

# For example:

#

# 102.54.94.97 rhino.acme.com # source Server

# 38.25.63.10 x.acme.com # x client Host

127.0.0.1 localhost

This file works according to the TCP/IP for Windows standard. Its role is to define IP addresses and

The mapping relationship of host name (hostname) is a provision that maps IP addresses and host name (hostname). In this rule, each paragraph is required to include only one mapping relationship, that is, an IP address and a host name that has a mapping relationship. The IP address is placed at the top of each paragraph, and the mapped host name (hostname) is separated by a space in the middle after the IP. For this section of the mapping instructions, "#" after the split with a text description.

Three. How the Hosts file works

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

We know that access to the Web site on the network, first through the DNS server to access the network domain name (xxxx.com) to resolve the IP address of the XXX.XXX.XXX.XXX, the computer can access the network domain name.

For each domain name request we have to wait for the domain name server to resolve the return of IP information, so that the efficiency of the network will be reduced, because DNS do domain name resolution and return IP will take time.

In order to improve the analytic efficiency of the domain name frequently visited, it is possible to achieve the goal by using the mapping relationship between domain name and IP in the hosts file. According to the Windows system, before a DNS request is made, the Windows system checks to see if there is a network domain name Mapping relationship in its hosts file. If so, call this IP address mapping, if not, and then present a domain resolution to a known DNS server. This means that the request level of hosts is higher than DNS.

Four. The working methods and specific functions of the hosts document

Now let's look at how the Hosts file works and what it does in concrete use.

1, speed up the domain name resolution

For frequently visited sites, we can configure the domain name and IP mapping relationship in hosts to improve the speed of domain name resolution. Because of the mapping relationship, when we enter the domain name computer can quickly resolve the IP, rather than requesting a DNS server on the network.

2, Convenient LAN users

In many units of the local area network, there will be servers available to users. However, because the local area network generally rarely set up DNS servers, access to these servers, to enter the difficult to remember the IP address. This is quite troublesome for many people. Now you can give these servers an easy to remember name, and then set up IP mapping in the hosts, so that when the next visit, as long as the name of the server to enter the line.

3, shielding the site

Now a lot of web sites without user consent to install a variety of plug-ins to your computer, some of which may be Trojans or viruses. For these sites we can use the hosts to map the site's domain name to the wrong IP or the local computer's IP, so no access. In the WINDOWSX system, the Convention 127.0.0.1 the IP address of the local computer, and 0.0.0.0 is the wrong IP address.

If, in hosts, we write the following:

127.0.0.1 # to screen site A

0.0.0.0 # Web site B to be screened

In this way, when the computer resolves domain A and b, it resolves to the native IP or the wrong IP, and achieves the purpose of shielding the Web site A and B.

4. Smooth Connection System

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

Five. Shielding sites that do not want to visit the example

Here are some collected from the use of hosts files on some of the web site shielding examples, a total of learning to use the Hosts file reference.

Example 1.

Add the following content in the Hosts file to screen the corresponding URLs defined in the file.

127.0.0.1 localhost

127.0.0.1 download.3721.com

127.0.0.1 3721.com #3721网络实名

127.0.0.1 3721.net #3721网络实名

127.0.0.1 www.wonmay.cn #完美站长站

127.0.0.1 cnsmin.3721.com #3721网络实名

127.0.0.1 cnsmin.3721.net #3721网络实名

127.0.0.1 www.10idc.net.cn #3721数据中心

127.0.0.1 download.3721.com #3721网络实名

127.0.0.1 download.3721.net #3721网络实名

127.0.0.1 www.10idc.com.cn #完美网络

127.0.0.1 www.3721.com #3721网络实名

127.0.0.1 www.3721.net #3721网络实名

Example 2.

Add the following content in the Hosts file to screen the corresponding URLs defined in the file.

127.0.0.1 localhost

127.0.0.1 bar.baidu.com #百度IE搜索伴侣

127.0.0.1 www.baidu.com #百度IE搜索伴侣

127.0.0.1 baidu.com #百度IE搜索伴侣

Finally, it is pointed out that the Hosts file configuration mapping is static, if the computer on the network changes, please update the IP address in time, otherwise it will not be accessible.

This article is the perfect webmaster station, please reprint the time to keep the URL http://www.wonmay.cn, thank you for your cooperation!

Through this article, I think most of the webmaster to deepen the understanding of domain name resolution, I hope everyone's technology more and more high, the site more do better!

The author QQ87608234 Network name think water, please many exchanges, Exchange QQ Group: 33892347, Welcome to join

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