Host Name/etc/hosts file

Source: Internet
Author: User
Tags website server

1,/Etc/hosts, Host name IPConfiguration file.

# Do not remove the following line, or various programs

# That require Network functionality will fail.

127.0.0.1 localhost. localdomain localhost

: 1 localhost6.localdomain6 localhost6

 

Hosts --- the static table lookup for host name (host name query static table)

In Linux,/etc/hosts is the file that configures the IP address and its corresponding host name. Here, the IP addresses of the local host or other hosts and their corresponding host names can be recorded.

Ora/RedHat or a release package based on fedora/RedHat. The host name configuration file is/etc/hosts.

Debian or Debian-based release. The host name configuration file is/etc/hostname and/etc/hosts.

The slackware host name configuration file is/etc/hosts.

2, The purpose of the configuration file;

On a LAN or internet, each host is assigned an IP address, which differentiates each host and can communicate with each other based on the IP address. But the IP address is not easy to remember, and all have domain names. In a LAN, each machine has a host name, which is used to distinguish hosts for mutual access.

For example, the definition in the/etc/hosts file

192.168.1.100 linumu100 test100

Suppose 192.168.1.100 is a website server. Enter http: // linumu100 or http: // test1000 on the webpage to open the web page of 192.168.1.100.

Generally, this file records the local IP address and Host Name:

172.0.0.1 localhost. localdomain localhost

3, Configuration file format description

Generally, the content of/etc/hosts is similar to the following:

127.0.0.1 localhost. localdomain localhost

192.168.1.100 linumu100.com linumu100

192.168.1.120 ftpserver ftp120

Generally, one host is at the end of each line of the hosts file. Each line consists of three parts, separated by spaces.

Part 1: network IP address;

Part 2: Host Name or domain name;

Part 3: Host Name alias;

Of course, each line can also be two parts, namely the Host IP address and host name.

What is the difference between a host name and a domain name:

The host name is usually used in the LAN. Through the hosts file, the host name is resolved to the corresponding IP address;

The domain name is usually used on the Internet, but if the local machine does not want to use domain name resolution on the Internet, then you can change the hosts file and add your own domain name resolution.

4, HostsWhat problems can files help solve?

4.1 slow remote logon to Linux Hosts

Sometimes the client wants to remotely log on to a Linux host, but it will wait a long time after entering the password. This is because the Linux host needs to resolve the IP address when returning information, if you add the IP address of the client to the hosts file of the Linux host, then you can log on to Linux from the client remotely.

4.2 dual-host Interconnection

When the two hosts are connected by two machines, you must set your own IP address and add your own IP address and host name to the hosts file of the other host.

4.3 One of the main functions is to simulate the offline environment. If the communication parties want to access each other through the domain names on the Internet in the same LAN, they only need to modify their own/etc/hosts file content.

 

 

After modifying the hosts file, Ping www. Baidu. Con. The result is as follows:

 

 

5, Hostname modification tool;

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

Show Host Name:

# Hostname

Display Host IP Address:

# Hostname-I

Set the host name temporarily:

# Hostname test100

Host Name/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.