方法一:
在/etc/resolv.conf中添加以下內(nèi)容
格式如下:
nameserver xxx.xxx.xxx.xxx
nameserver xxx.xxx.xxx.xxx
后面的ip地址是dns服務(wù)器的地址,也可以添加多個(gè)地址,如:
nameserver 114.114.114.114
圖方便可以直接
echo "nameserver 114.114.114.114" >> /etc/resolv.conf
注意:echo后面">"是清空文件夾內(nèi)容添加內(nèi)容,而">>"是追加內(nèi)容
然后
service network restart
方法二:
[root@Aaronwang ~]# pingwww.aaronw.cn
ping: unknown hostwww.aaronw.cn
[root@Aaronwang ~]#ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.537 ms
ping得通IP但是不通域名
[root@Aaronwang ~]#cat /etc/host.conf
order bind,hosts
解決方法如下:
[root@Aaronwang ~]# grep host /etc/nsswitch.conf
#hosts: db files nisplus nis dns
hosts: files
主機(jī)只找文件不走dns,將其該成hosts: files dns 即可