1, host name:
Whether on the LAN or the Internet, each host has an IP address to differentiate between this host and its host, that is, the IP address is the host's number.
Public network: The IP address is not easy to remember, so there is a domain name. Domain names exist only in the public network (the INtERNET), each domain name corresponds to an IP address, but an IP address can have multiple domain names.
LAN: Each machine has a host name, for the host and the host to facilitate the separation, you can set the host name for each machine, in order to easily remember the way to access each other. For example, we can be named according to the function of each machine in LAN.
Host name-related profiles:/etc/hosts
2. hostname configuration file:
The hostname configuration file is mostly/etc/hosts
The hosts configuration file is the method used to map the host name to the IP address, which is relatively simple. But this mapping is only a local machine mapping, which means that each machine is independent, and all computers can not access each other through hostname.
For example:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
127.0.0.1 localhost.localdomain localhost
192.168.1.195 Debian.localdomain Debian
In general, the content of the hosts is about the hostname (Hostname) definition, each behavior of a host, each line consists of three parts, each part separated by a space. Where the # starts with a line that is not explained by the system.
The first part: Network IP address.
Part two: hostname. Domain name, note that there is a half-width point between the host name and the domain name.
The second part: hostname (hostname alias), is actually the host name.
Of course, each line can also be two parts, that is, the host IP address and host name; for example 192.168.1.195 Debian
Then we have three host, each do a different thing, one to do mail server, one to do FTP server, one to do SMB server, so we can design hostname;
127.0.0.1 localhost.localdomain localhost
192.168.1.2 Ftp.localdomain FTP
192.168.1.3 Mail.localdomain Mail
192.168.1.4 smb.localdomin SMB
The contents of this configuration file are written to each machine's/etc/hosts content separately, so that the three LAN machines can be accessed through hostname.
3. The difference between host name (Hostname) and domain name (domains)
Hostname is the name of the machine itself, the domain name is used to resolve to the IP. But it is worth saying that in the local area network, the hostname can also be resolved to the IP, such as the example we said earlier;
Display host Name:
# Hostname
Root1
The host name of this host is ROOT1, and no parameter is the hostname of the host that is used to display the current operation.
Temporarily set host name:
We can use Hostname after the host name, so that we can set the host name of the current operation, such as we want to set the hostname to ROOT2;
# Hostname Root2
Root2
Using the Hostname tool to set the hostname is only temporary, the next time you restart the system, this hostname will not exist, so you want to modify the hostname, you want to always be effective, or to modify the hostname with the previous configuration file/etc/hosts;
Show host IP:
[Email protected] ~]# hostname-i
192.168.10.3
A detailed description of the Hosts file under Linux