centos7 ping: www.baidu.com: Name or service not known的解决方法

出现的问题:

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

解决方法:

1、查看网络连接模式

centos7 ping: www.baidu.com: Name or service not known的解决方法_第1张图片

2、查看NAT设置,记住NAT设置中的子网掩码、网关IP两项,还有虚拟主机的IP地址(就是安装centos7系统分配的IP地址)

centos7 ping: www.baidu.com: Name or service not known的解决方法_第2张图片

centos7 ping: www.baidu.com: Name or service not known的解决方法_第3张图片

3、vim /etc/sysconfig/network-scripts/ifcfg-ens33,修改配置文件

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="3f9720b0-5e2f-4b91-b2e7-88bc27f7bc35"
DEVICE="ens33"
ONBOOT="yes"
IPADDR="10.0.0.153"
NETMASK="255.255.255.0" 
DNS1="8.8.8.8"  
DNS2="8.8.4.4"  
GATEWAY="10.0.0.2" 

 

4、重启网络服务:service network restart

[root@centos7 ~]#service network restart
Restarting network (via systemctl):                        [  OK  ]

5、测试效果

[root@centos7 ~]#ping www.baidu.com
PING www.wshifen.com (103.235.46.39) 56(84) bytes of data.
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=1 ttl=128 time=76.1 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=2 ttl=128 time=75.7 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=3 ttl=128 time=73.3 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=4 ttl=128 time=72.2 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=5 ttl=128 time=111 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=6 ttl=128 time=71.2 ms
^C
--- www.wshifen.com ping statistics ---
6 packets transmitted, 6 received, 0% packet loss, time 5006ms
rtt min/avg/max/mdev = 71.248/80.081/111.770/14.283 ms
[root@centos7 ~]#

6、搞定。

 

 

你可能感兴趣的:(Linux运维,linux,运维)