Home > Article > Operation and Maintenance > Linux server hosts file configuration
linux server hosts file configuration
The hosts file is a file in the Linux system responsible for rapid resolution of IP addresses and domain names, and is saved in ASCII format In the "/etc" directory, the file name is "hosts".
The hosts file contains the mapping between IP addresses and host names, and also includes aliases for the host names. In the absence of a domain name server, all network programs on the system query this file to resolve the IP address corresponding to a certain host name, otherwise they need to use a DNS service program to solve the problem. Usually, commonly used domain names and IP address mappings can be added to the hosts file to achieve quick and convenient access.
Let’s introduce the methods and steps to modify the hosts configuration file:
Required tools: vim/vi
1, Install vim editor
sudo apt install vim -y # debian sudo yum install vim -y # readhat
2. Use the editor to modify the hosts file
1. sudo vim /etc/hosts 2. 按下 i 键进入编辑模式
The format of the hosts file is as follows:
IP address host name/domain name
First part: network IP address;
Second part: host name or domain name;
Third part: host name Alias;
For example:
127.0.0.1 localhost.localdomain localhost 192.168.1.100 linmu100.com linmu100 192.168.1.120 ftpserver ftp120
3. Save after modification
1. 按下ESC 2. 输入 :wq
(Online video tutorial sharing: linux Video tutorial)
The above is the detailed content of Linux server hosts file configuration. For more information, please follow other related articles on the PHP Chinese website!