问题:
当你连接不上虚拟机(虚拟机能正常打开,但是连接工具如CRT等连接不上或者连接超时),用ifconfig查看网络信息发现只有以下信息
[root@node1 ~]# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 14 bytes 784 (784.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 14 bytes 784 (784.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:f6:83:da txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
正常连接时输入ifconfig查看网络信息应是以下信息
[root@node1 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.88.100 netmask 255.255.255.0 broadcast 192.168.88.255
inet6 fe80::20c:29ff:fe66:13f2 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:66:13:f2 txqueuelen 1000 (Ethernet)
RX packets 9 bytes 785 (785.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 57 bytes 8137 (7.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 16 bytes 896 (896.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 896 (896.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:f6:83:da txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
相比较缺少了ens33这段
解决方式:
依次执行一下4个命令
- systemctl stop NetworkManager -> 临时关闭
- systemctl disable NetworkManager -> 永久关闭网络管理命令
- systemctl start network.service -> 开启网络服务
- service network restart -> 重启网络服务
systemctl stop NetworkManager --临时关闭
systemctl disable NetworkManager --永久关闭网络管理命令
systemctl start network.service -- 开启网络服务
service network restart --重启网络服
效果:
[root@node1 ~]# systemctl stop NetworkManager
You have new mail in /var/spool/mail/root
[root@node1 ~]# 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@node1 ~]# systemctl start network.service
[root@node1 ~]# service network restart
Restarting network (via systemctl): [ OK ]
[root@node1 ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.88.100 netmask 255.255.255.0 broadcast 192.168.88.255
inet6 fe80::20c:29ff:fe66:13f2 prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:66:13:f2 txqueuelen 1000 (Ethernet)
RX packets 9 bytes 785 (785.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 57 bytes 8137 (7.9 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10<host>
loop txqueuelen 1000 (Local Loopback)
RX packets 16 bytes 896 (896.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 16 bytes 896 (896.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:f6:83:da txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0