CentOS7无法上网

未连接网络,ping不通

[lj@localhost ~]$ su
密码:
[root@localhost lj]# ping www.baidu.com
ping: www.baidu.com: 未知的名称或服务

还原网络设置
在这里插入图片描述
选择NAT模式

在这里插入图片描述
修改网络配置文件

vi /etc/sysconfig/network-scripts/ifcfg-eth0

在这里插入图片描述
重启网络

service network restart

尝试ping百度,成功

[root@localhost lj]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
[root@localhost lj]# service network restart
Restarting network (via systemctl):                        [  确定  ]
[root@localhost lj]# ping www.baidu.com
PING www.a.shifen.com (39.156.66.14) 56(84) bytes of data.
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=1 ttl=128 time=19.1 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=2 ttl=128 time=208 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=3 ttl=128 time=18.4 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=4 ttl=128 time=21.4 ms
64 bytes from 39.156.66.14 (39.156.66.14): icmp_seq=5 ttl=128 time=20.9 ms
^C
--- www.a.shifen.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 13046ms


版权声明:本文为qq_40713201原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。