Home >Operation and Maintenance >Linux Operation and Maintenance >Detailed explanation of the file description of /etc/host* in Linux system services (1)

Detailed explanation of the file description of /etc/host* in Linux system services (1)

黄舟
黄舟Original
2017-06-06 10:39:524081browse

1./etc/hosts

>man hosts


1. Function: Host name query Static table; mainly used for conversion between IP address and computer host name.

/ETC/HOSTS file format, each line represents an IP address; each line consists of three parts:

ip_address canonical_hostname The host name or domain name of #ip address specifications

# Note:

(1)

Note

## 内容#(2) Host Names is only only It can contain numbers, letters, hyphens (-), and dots (.); it must start with a letter and end with a letter or number. (3) Host name alias is optional

(4) Although the host table has been replaced by DNS, it is still widely used:

--System boot: Most systems have a small host table, which contains the names and address information of important hosts in the local network. This is useful when DNS is not enabled.

--NIS: Websites that use NIS will use the host table as the input to the NIS host database. Even if NIS uses DNS, most NIS websites still use the host table as the backup entry for all local hosts. --Isolated node: In a LAN that is not connected to the internet, the host table will be used as a replacement for DNS. If the local information rarely changes, and the local LAN is not connected to the Internet, DNS has no advantage.

The above-mentioned isolated node means that when establishing a LAN without a connection to the Internet, you can use /etc/hosts to specify the mapping between the host name and IP that needs to be connected. Those that are not included in the /etc/hosts mapping , generally unable to connect.

(5) Modifications to this file usually take effect immediately unless this file is cached.

2. Example

EXAMPLE       127.0.0.1       
localhost       192.168.1.10    
foo.mydomain.org       foo       
192.168.1.13    bar.mydomain.org       
bar       146.82.138.7    
master.debian.org      master       
209.237.226.90  www.opensource.org
Note:

After entering the IP and its host name in /etc/hosts, you can use the host name for LAN

Remote login

or connect, it is faster;2./etc/hostname This file can only contain the host name

The way to permanently modify the host name is to modify /etc/hostname, which will take effect after restarting;

Temporary modification: You can use hostname new-host-name in the terminal to make temporary changes Once the system is restarted, the hostname will be changed back to the original one.

3./etc/host.conf1. There are two methods for domain name resolution:

(1) Use DNS system

(2) Use the /etc/hosts file

/etc/host.conf to specify the order of domain name resolution methods.

The general content is:

##order: Specify which order to use.

hosts: Use /etc/hosts file resolution

bind: Use DNS resolution.

The above is the detailed content of Detailed explanation of the file description of /etc/host* in Linux system services (1). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn