未连接网络,ping不通

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

还原网络设置

CentOS7无法上网_NAT


选择NAT模式

CentOS7无法上网_linux_02


修改网络配置文件

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

CentOS7无法上网_linux_03


重启网络

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