1. 程式人生 > >ping百度(外網)出現:unknown host www.baidu.com問題解決

ping百度(外網)出現:unknown host www.baidu.com問題解決

ping 百度出現:(ping www.baidu.com)
"ping: unknown host www.baidu.com"
ping 閘道器確定是否連線上路由器,並且路由器是否連線上網: [[email protected] ~]#ping 192.168.8.1
PING 192.168.8.1 (192.168.8.1) 56(84) bytes of data.
64 bytes from 192.168.8.1: icmp_seq=1 ttl=254 time=513 ms
64 bytes from 192.168.8.1: icmp_seq=2 ttl=254 time=1112 ms
64 bytes from 192.168.8.1: icmp_seq=3 ttl=254 time=594 ms
64 bytes from 192.168.8.1: icmp_seq=4 ttl=254 time=85.4 ms
檢查DNS服務是否已經設定
[
[email protected]
~]#cat /etc/resolv.conf
[[email protected] ~]#vi /etc/resolv.conf
裡面檔案為空,則新新增一條DNS到該檔案中:
search localdomain
nameserver 119.29.29.29
確認閘道器已設定(RHEL系統)
[[email protected] ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
network=192.168.8.1
判斷route是否有此路由並新增
[[email protected]
network-scripts]#route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.8.0    *              255.255.255.0  U    0      0        0 eth0
169.254.0.0    *              255.255.0.0    U    0      0        0 eth0 [[email protected] network-scripts]#route add default gw 192.168.8.1
[[email protected] network-scripts]#route
Kernel IP routing table
Destination    Gateway        Genmask        Flags Metric Ref    Use Iface
192.168.8.0    *              255.255.255.0  U    0      0        0 eth0
169.254.0.0    *              255.255.0.0    U    0      0        0 eth0
default        192.168.8.1    0.0.0.0        UG    0      0        0 eth0
重啟network服務
[[email protected] network-scripts]# service network restart
測試結果(成功):
[[email protected] network-scripts]# ping www.baidu.com
PING www.a.shifen.com (14.215.177.37) 56(84) bytes of data.
64 bytes from 14.215.177.37: icmp_seq=1 ttl=54 time=30.9 ms
64 bytes from 14.215.177.37: icmp_seq=2 ttl=54 time=49.7 ms