About/etc/hosts Files

Source: Internet
Author: User
Tags in domain

Http://blog.sina.com.cn/s/blog_6714fba701018pip.html


1,/etc/hosts, host name what IP profile.
Hosts---the static table lookup for Host name (hostname query static tables)

Linux/etc/hosts is a file that configures the IP address and its corresponding hostname, where you can record the IP and its corresponding host name of the machine or other host.
Different versions of Linux, this configuration file may also be different. /etc/hostname, for example, is the corresponding file in Debian.

2, the use of the configuration file;

This file can configure the host IP and its corresponding host name, and the role of the server-type Linux system should also be ignored.
On the LAN or the Internet, each host is made up of an IP address that distinguishes each host and can communicate based on IP. But the IP address is not convenient memory, all have the domain name again. In a local area network, each machine has a host name that is used to differentiate between hosts for easy access.

The configuration file for the Linux hostname is/etc/hosts, which tells the host which IP is corresponding to those domain names, and which host names correspond to which IP:
such as the definition in a file
192.168.1.100 linumu100 test100
Assuming that 192.168.1.100 is a Web server, entering http://linumu100 or http://test1000 in a Web page opens 192.168.1.100 's Web page.

Typically this file first records the IP and host name of the computer:
172.0.0.1 localhost.localdomain localhost

3, configuration file format description

General/etc/hosts content generally has the following similar content:
127.0.0.1 localhost.localdomain localhost
192.168.1.100 linumu100.com linumu100
192.168.1.120 Ftpserver ftp120

In general, the hosts file at the end of each line of a host, each row consists of three parts, each part is separated by a space.

The first part: Network IP address;
Part II: Host name or domain name;
Part III: host name alias;

Of course, each row can also be two parts, that is, the host IP address and host name.

Difference between host name (hostname) and domain name (in domain):
Host name is usually used in the LAN, through the Hosts file, the host name is resolved to the corresponding IP;
Domain names are usually used on the Internet, but if this computer does not want to use the domain name resolution on the Internet, then you can change the Hosts file and join your own domain name resolution.

What problems 4,hosts files can help solve

4.1 Remote login to the Linux host too slow problem
Sometimes the client wants to remotely log on to a Linux host, but each login password will wait a long time to enter, this is because the Linux host in the return of information needs to resolve IP, if the hosts in the Linux host file in advance to join the client's IP address, Then telnet to Linux from the client will be quick.
4.2 Dual-Computer interconnection
When two hosts are only two-machine interconnection, when both hosts need to set their own IP, at the same time in each other's Hosts file to add their own IP and host name.

5, the Host name modification tool hostname;

Hostname---Show or set the system ' s host name

Display host Name:
#hostname
Show host IP:
#hostname-I.
Set host name temporarily:
#hostname test100

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.