域名服务器(DNS)配置文件

位置:/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-6loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

在默认情况下,在进行域名解析时,系统会首先来查找/etc/hosts文件,然后才去查询DNS服务器。如果你想更改这个顺序,则可以修改/etc/nsswitch.conf文件中hosts一行的顺序。

posted @ 2012-06-18 18:35  为了这有限的生命  阅读(901)  评论(0编辑  收藏  举报