A detailed description of the Hosts file under Linux
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
Hostname configuration file:
The hostname configuration file is mostly/etc/hosts
The hosts configuration file is the method used to map host names to IP addresses. 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.
Differences 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 LAN, the hostname can also be resolved to the IP.
<wiz_tmp_tag id= "Wiz-table-range-border" contenteditable= "false" style= "Display:none;" >
A detailed description of the Hosts file under Linux