linux虚拟机连不上网,网卡重置轻松解决。 不知道改了什么配置,虚拟机的网络不能用了,是因为看时间的时候发现时间不对,然后进行校准,结果发现无法联网。
[root@localhost ~]# ping www.baidu.comping: www.baidu.com: 未知的名称或服务重复重启网卡,也按照网上教程重新配置了虚拟机的网络适配器设置,发现还是不管用,最后发现简单两步就能搞定:
先用ifconfig或者ip addr命令查看自己的网卡名称,如果没有ifconfig命令,可以根据这篇文章进行安装:linux最小化安装配置ifconfig命令
#查看网络信息的命令,二选一即可:ifconfig 或者使用:ip addr,如下图[root@localhost ~]# ifconfigens33: flags=4163 mtu 1500inet 192.168.58.129 netmask 255.255.255.0 broadcast 192.168.58.255inet6 fe80::13b5:30a2:83dc:deee prefixlen 64 scopeid 0x20ether 00:0c:29:e2:a3:94 txqueuelen 1000 (Ethernet)RX packets 1138 bytes 91698 (89.5 KiB)RX errors 0 dropped 0 overruns 0 frame 0TX packets 667 bytes 83431 (81.4 KiB)TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0如上,ens33即为我的网卡名称。使用如下命令进行卸载和加载即可:
# 停止网卡服务systemctl stop network.service# 卸载网卡ifconfig ens33 down# 加载网卡ifconfig ens33 up注意,使用卸载和加载命令的时候,一定要再虚拟机里面进行,否则网卡停用后,会导致工具连接断开。 最后使用命令检验是否可以联网:
ping www.baidu.com