未连接网络,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
如果还是不行可以尝试重启网络
systemctl stop NetworkManager
systemctl disable NetworkManager
重启之后,网络恢复正常
[root@localhost lj]# systemctl stop NetworkManager
[root@localhost lj]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service.
[root@localhost lj]# ping www.baidu.com
PING www.a.shifen.com (220.181.38.149) 56(84) bytes of data.
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=1 ttl=128 time=6.15 ms
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=2 ttl=128 time=6.66 ms
64 bytes from 220.181.38.149 (220.181.38.149): icmp_seq=3 ttl=128 time=6.54 ms
^C
--- www.a.shifen.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2004ms
rtt min/avg/max/mdev = 6.155/6.456/6.666/0.218 ms
或者开启NetworkManager
systemctl start NetworkManager.service