Teach everyone to know the hosts file of Unix system

  

The system we usually know is Microsoft's system, but Linux system and Unix system are also welcomed by some users. Since everyone is not familiar with these two operating systems, then today we will introduce you to the Unix system. Hosts file.

1. About /etc/host, hostname and IP configuration file

Hosts - The static table lookup for host name

Linux/Etc/hosts is a file that configures the ip address and its corresponding host name. Here you can record the ip of the local or other host and its corresponding host name. This configuration file may be different for different linux versions. For example, the corresponding file for Debian is /etc/hostname.

2. Configuration File

This file can be configured with the host ip and the corresponding host name. The role of the server type Linux system is not negligible. On a LAN or INTERNET, each host has an IP address that separates each host and can communicate based on ip. But the IP address is not convenient to remember, so there is a domain name. In a local area network, each machine has a host name that is used to distinguish hosts and facilitate mutual access.

The relevant configuration file for Linux hostname is /etc/hosts; this file tells the host which domain names correspond to those ips, and which hostnames correspond to ip:

For example, there is such a definition in the file.

192.168.1.100 linumu100 test100

Suppose 192.168.1.100 is a web server. Enter http://linumu100 or http://test100 in the web page to open the web page 192.168.1.100. .

Normally this file first records the ip and hostname of the machine:

127.0.0.1 localhost.localdomain localhost

3. Configuration File Format Description

The contents of the general /etc/hosts generally have the following contents:

127.0.0.1 localhost.localdomain localhost

192.168.1.100 linmu100.com linmu100

192.168. 1.120 ftpserver ftp120

In general, each host file is a host. Each line consists of three parts, each separated by a space. The line at the beginning of ## is used for explanation and is not explained by the system.

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; for example, 192.168.1.100 linmu100.

Here you can slightly explain the difference between the hostname (hostname) and the domain name (Domain): the hostname is usually used in the LAN, through the hosts file, the hostname is resolved to the corresponding ip; the domain name is usually on the internet Use, but if the machine does not want to use the domain name resolution on the internet, then you can change the hosts file and add your own domain name resolution.

Copyright © Windows knowledge All Rights Reserved