原 Linux:ping不通baidu.com

原 Linux:ping不通baidu.com,第1张

概述 如果某台Linux服务器ping不通域名, 如下提示:  [root@localhost ~]# ping www.baidu.com ping: unknown host www.baidu.com 首先确定已经连接上路由器,并且路由器能够访问外网,可以通过访问网关进行确定 [root@localhost ~]# ping 8.8.8.8 PING 192.168.1.1 (192.168.1

 如果某台Linux服务器Ping不通域名,如下提示: 
[root@localhost ~]# Ping www.baIDu.com
Ping: unkNown host www.baIDu.com

首先确定已经连接上路由器,并且路由器能够访问外网,可以通过访问网关进行确定

[root@localhost ~]# Ping 8.8.8.8
Ping 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=2.96 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=1.75 ms

如果确定网络没问题的情况下,可以通过如下步骤寻找解决办法: 
1) 确定设置了域名服务器,没有的话,建议设置Google的公共DNS服务,它应该不会出问题的 

@localhost ~]# cat /etc/resolv.conf

search localdomain

因为我的DNS没有设置所以导致了Ping外网Ping不通。将dns添加到该文件中

@localhost ~]# vi /etc/resolv.conf

nameserver 202.98.96.68
nameserver 61.139.2.69
~

或者加入192.168.1.1 (默认网关)

2) 确保网关已设置 

# grep GATEWAY /etc/sysconfig/network-scripts/ifcfg* 
——————————————————————- 
/etc/sysconfig/network-scripts/ifcfg-eth0:GATEWAY=192.168.40.1 
——————————————————————- 

如果未设置,则通过如下方式增加网关: 

# route add default gw 192.168.40.1 

或者手工编写/etc/sysconfig/network-scripts/ifcfg*文件后,重启network服务: 

# service network restart 

3) 确保可用dns解析 

# grep hosts /etc/nsswitch.conf 
——————————————————————- 
hosts:      files dns 
——————————————————————- 

如果以上哪个有问题,修正后,再测试,应该就没问题了: 

#Ping -c 3 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 
64 bytes from 220.181.6.175: icmp_seq=1 ttl=50 time=8.45 ms 
64 bytes from 220.181.6.175: icmp_seq=2 ttl=50 time=8.97 ms 
— www.a.shifen.com Ping statistics — 
3 packets transmitted,3 received,0% packet loss,time 2002ms 
rtt min/avg/max/mdev = 8.450/8.977/9.511/0.446 ms,pipe 2

原文地址:https://blog.csdn.net/qq_35370485/article/details/77844860

总结

以上是内存溢出为你收集整理的原 Linux:ping不通baidu.com全部内容,希望文章能够帮你解决原 Linux:ping不通baidu.com所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1024903.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存