標籤:style color os ar 檔案 2014 art 問題 sp
2014-09-06
當 Linux 伺服器 ping 不通網域名稱, 出現如下提示:
[[email protected] ~]# ping www.baidu.com
ping: unknown host www.baidu.com
1.檢測網路
首先確定已經串連上路由器,並且路由器能夠訪問外網,可以通過訪問網關進行確定
[[email protected] ~]# ping 192.168.2.251
PING 192.168.2.251 (192.168.2.251) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=2.96 ms
如果確定網路沒問題的情況下, 可以通過如下步驟尋找解決辦法:
1) 確定設定了網域名稱伺服器, 沒有的話, 建議設定 Google 的公用 DNS 服務, 它應該不會出問題的
[[email protected] ~]# vi /etc/resolv.conf
nameserver 192.168.2.251
2) 確保網關已設定
# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg*
/etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=192.168.2.251
如果未設定, 則通過如下方式增加網關:
# route add default gw 192.168.2.251
或者手工編寫/etc/sysconfig/network-scripts/ifcfg*檔案後, 重啟 network 服務:
# service network restart
3) 確保可用 dns 解析
# grep hosts /etc/nsswitch.conf
hosts: files dns
成功結果:
如果以上哪個有問題, 修正後, 再測試, 應該就沒問題了:
#ping www.baidu.com
PING www.a.shifen.com (220.181.6.175) 56(84) bytes of data.
64 bytes from 220.181.6.175: icmp_seq=0 ttl=50 time=9.51 ms
Linux 伺服器ping不通網域名稱