故障现象

1.服务器无法被ping通 2.GUI界面右上角看不到网卡图标

  • 故障时网络图标消失后的样子

QQ截图20240304152141.png

  • 正常情况GUI显示的网络图标

QQ截图20240304152251.png

  • ip addr网卡没有地址
┌──(root㉿kali)-[~]
└─# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host proto kernel_lo 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN group default qlen 1000
    link/ether 00:50:56:31:d1:cf brd ff:ff:ff:ff:ff:ff
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:90:5c:6c:14 brd ff:ff:ff:ff:ff:ff
  • nmcli device status状态为unmanaged
┌──(root㉿kali)-[~]
└─# nmcli device status 
DEVICE   TYPE      STATE   CONNECTION 
docker0  bridge    未托管  --         
eth0     ethernet  未托管  --         
lo       loopback  未托管  --         
  • nmcli connection show状态为unmanaged
┌──(root㉿kali)-[~]
└─# nmcli connection show
NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  06f3e43a-f4ba-4da2-8fd5-f509e68554f5  ethernet  --     

解决办法

//确定NetworkManager是否已接管了系统的网络连接管理
┌──(root㉿kali)-[~]
└─# nmcli networking
disabled

//若没有解决则需要手动开启接管
┌──(root㉿kali)-[~]
└─# nmcli networking
nmcli networking on

//接管后恢复正常
┌──(root㉿kali)-[~]
└─# nmcli connection show
NAME                UUID                                  TYPE      DEVICE 
Wired connection 1  06f3e43a-f4ba-4da2-8fd5-f509e68554f5  ethernet  eth0   
lo                  7b145851-8953-4523-a1e7-d4106cfaa2c3  loopback  lo     

┌──(root㉿kali)-[~]
└─# nmcli device status  
DEVICE   TYPE      STATE         CONNECTION         
eth0     ethernet  已连接        Wired connection 1 
lo       loopback  连接(外部)  lo                 
docker0  bridge    未托管        --                 

可能的其他解决方法

  • 或者也可以修改NetworkManager.service配置文件后再重启服务解决;配置文件路径是:/var/lib/NetworkManager/NetworkManager.state
cat /var/lib/NetworkManager/NetworkManager.state
[main]
NetworkingEnabled=true
WirelessEnabled=true
WWANEnabled=true
  • 注意:操作顺序先stop服务,再修改配置文件;最后启动服务。
systemctl stop NetworkManager
vi /var/lib/NetworkManager/NetworkManager.state
cat /var/lib/NetworkManager/NetworkManager.state

[main]
NetworkingEnabled=true      //修改为true
WirelessEnabled=true
WWANEnabled=true

systemctl start NetworkManager

故障原因

未知系统原因导致NetworkManager没有正确接管系统的网络连接管理;其实,没有调整过NetworkManager配置的情况下重启服务器也是可以解决的,但是极端情况下要避免服务器的重启操作,这个方法会很有效