ping百度(外网)出现:unknown host www.baidu.com问题解决

来源:互联网 发布:itunes软件怎么下载 编辑:程序博客网 时间:2024/06/05 05:51
ping 百度出现:(ping www.baidu.com)
"ping: unknown host www.baidu.com" 

ping 网关确定是否连接上路由器,并且路由器是否连接上网:
[root@vmhost ~]# 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服务是否已经设置
[root@localhost ~]# cat /etc/resolv.conf
[root@localhost ~]# vi /etc/resolv.conf
里面文件为空,则新添加一条DNS到该文件中:
search localdomain
nameserver 119.29.29.29

确认网关已设置(RHEL系统)
[root@vmhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
network=192.168.8.1

判断route是否有此路由并添加
[root@vmhost 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

[root@vmhost network-scripts]# route add default gw 192.168.8.1

[root@vmhost 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服务
[root@vmhost network-scripts]# service network restart

测试结果(成功):
[root@vmhost 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

原创粉丝点击