位置:/etc/resolv.conf
格式如下:
search localdomain
nameserver 192.168.1.1
nameserver 2020.102.14.68
1. /etc/hosts文件
如果你没有自己的DNS服务器,或者某些主机没有在你的DNS服务器注册,那么你可以把它们的主 机名和IP地址写在/etc/hosts文件中,这样就可以解决这些主机的域名解析的问题了。默认的/etc/hosts文件内容如下:127.0.0.1 localhost
127.0.0.1 ubuntu.localdomain ubuntu
# The following lines are desirable for ipv6 capable hosts
::1 ip6-localhost ip-6loopbackfe00::0 ip6-localnetff00::0 ip6-mcastprefixff02::1 ip6-allnodesff02::2 ip6-allroutersff02::3 ip6-allhosts在默认情况下,在进行域名解析时,系统会首先来查找/etc/hosts文件,然后才去查询DNS服务器。如果你想更改这个顺序,则可以修改/etc/nsswitch.conf文件中hosts一行的顺序。