[root@localhost ~]# ping www.baidu.com
提示 ping: unknown host
這是因爲DNS服務器沒有配置好,如果網絡沒有問題,可以按下面的步驟進行檢查:
1) vi /etc/resolv.conf
添加
nameserver 192.168.59.2 本機的網關地址(路由器的地址)
search localdomain # search 參數指定域名查找順序
2)設置網關
vi /etc/sysconf/network-scripts/ifcfg-eth0
添加
GATEWAY=192.168.59.2
或者
使用命令設置
route add default gw 192.168.59.2
然後重新啓動網絡服務:
service network restart
3)確保可用DNS解析
[root@localhost Desktop]# grep hosts /etc/nsswitch.conf
輸出
hosts: files dns
該文件/etc/nsswith.conf是SUN公司開發的一種擴展name server switch。用於設置文件讀取的順序,如是先讀取/etc/hosts文件,還是先查找DNS服務器。
hosts: files dns 指定先查找/etc/hosts文件,如果失敗,則到DNS服務器查找與域名相對應的主機信息。
4)測試DNS
ping www.centoscn.com
原文鏈接點擊打開鏈接