ping外网:unknown host www.baidu.comc排查
ping 百度出现:(ping www.baidu.com)
"ping: unknown host www.baidu.com"
1.ping 网关确定是否连接上路由器,并且路由器是否连接上网:
[root@vmhost ~]# ping 192.168.8.1
2.检查DNS服务是否已经设置
[root@localhost ~]# cat /etc/resolv.conf [root@localhost ~]# vi /etc/resolv.conf
里面文件为空,则新添加一条DNS到该文件中:
search localdomain nameserver 119.29.29.29
3.确认网关已设置(RHEL系统)
[root@vmhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0 network=192.168.8.1
4.判断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
设置route
[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
5.重启network服务
[root@vmhost network-scripts]# service network restart
6.测试(成功):
[root@vmhost network-scripts]# ping www.baidu.com