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

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

  • 5
    点赞
  • 37
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值