CentOS7 ping: www.baidu.com: Name or service not known解决方案

关注我,升职加薪就是你!
问题:

[root@localhost max]# ping www.baidu.com
ping: www.baidu.com: Name or service not known

解决方案:
编辑指令:#vi /etc/sysconfig/network-scripts/ifcfg-ens33
添加阿里巴巴(114.114.114.114)和谷歌(8.8.8.8)的域名服务器

DNS1=8.8.8.8
DNS2=8.8.4.4
DNS3=114.114.114.114

编辑指令:# vi /etc/resolv.conf

nameserver 8.8.4.4
nameserver 114.114.114.114

编辑指令:# vi /etc/sysconfig/network

NETWORKING=yes
HOSTNAME=CentOS7-32bit-B

重启网络,编辑指令:# service network restart

Restarting network (via systemctl):                        [  OK  ]

编辑指令测试是否能ping成功。
本机:

[root@localhost max]# ping 192.168.0.185
PING 192.168.0.185 (192.168.0.185) 56(84) bytes of data.
64 bytes from 192.168.0.185: icmp_seq=1 ttl=64 time=0.241 ms
64 bytes from 192.168.0.185: icmp_seq=2 ttl=64 time=0.559 ms
64 bytes from 192.168.0.185: icmp_seq=3 ttl=64 time=0.572 ms
^C
--- 192.168.0.185 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.241/0.457/0.572/0.154 ms

宿主主机:

[root@localhost max]# ping 192.168.0.186
PING 192.168.0.186 (192.168.0.186) 56(84) bytes of data.
64 bytes from 192.168.0.186: icmp_seq=1 ttl=64 time=0.031 ms
64 bytes from 192.168.0.186: icmp_seq=2 ttl=64 time=0.061 ms
^C
--- 192.168.0.186 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.031/0.046/0.061/0.015 ms

外网:

[root@localhost max]# ping www.baidu.com
PING www.baidu.com (14.215.177.38) 56(84) bytes of data.
64 bytes from www.baidu.com (14.215.177.38): icmp_seq=1 ttl=54 time=6.88 ms
64 bytes from www.baidu.com (14.215.177.38): icmp_seq=2 ttl=54 time=7.48 ms
^C
--- www.baidu.com ping statistics ---
9 packets transmitted, 2 received, 77% packet loss, time 8020ms
rtt min/avg/max/mdev = 6.885/7.186/7.488/0.313 ms

好了,问题完美解决。
关注我,升职加薪就是你!

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

徐先生Paul

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值