web123456

Network configuration file under linux

1./etc/hosts
The hosts file is a text file, opened with vim, and it stores some corresponding relationships between IP and domain names.

vim /etc/hosts
  • 1

Contents inside

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.171.128 www.baidu.com
192.168.171.128 www2.baidu.com
192.168.171.137 www.yjking.com
  • 1
  • 2
  • 3
  • 4
  • 5

/ # parser query order configuration file

vim /etc/host.conf
  • 1
order hosts, bind 
multi on
  • 1
  • 2

# means to query the local hosts file first, if there is no result, then try to find the BIND dns server

  1. /etc/ # is a DNS client configuration file, used to set the IP address and DNS domain name of the DNS server, and also includes the host's domain name search order.
vim /etc/resolv.conf
  • 1
; generated by /usr/sbin/dhclient-script
search localdomain     #localdomain is searching for local domain lan is searching for local area network
nameserver 192.168.171.2  
  • 1
  • 2
  • 3