Requirement: After the server restarts, remote connection to the server is not possible. You can only log in using VNC. Then ping ip prompts that Network is unreachable. The IP addr network card is also in UP status, but the IP address cannot be obtained, and the entire server network is unavailable.
First, check the status of the NetworkManager service with the following command:
Found to be in an active (running) state.
Using the nmcli connection show command, you will see that a network card is disconnected from the disconnected device. Solution:
Check the current network card associated connection name (NAME) and boot status:
Explicitly enable automatic connection on startup ( <连接NAME> replace with the name found in the previous step):
As soon as you see the AUTOCONNECT column change to yes, it means the configuration has been written to the hard drive (/etc/NetworkManager/system-connections/ or ifcfg-xxx), and restarting the server will not fail.
In NetworkManager, concepts are divided into two layers:
- device: refers to physical or virtual network interface interfaces (such as eth1, ens34).
- connection: refers to the network configuration file stored on the hard drive (such as Wired connection 1 or /etc/sysconfig/network-scripts/ifcfg-xxx).
The underlying behaviors of the two commands are completely different:
1. nmcli connection up<名称>: Go to the configuration file list and find the configuration named and <名称> activate it.
If this network card does not have a corresponding configuration file, or the name of the configuration file differs from the network card name (for example, the network card is called ens34 but the configuration file is System ens34), directly typing nmcli c up ens34 will cause an error that the connection cannot be found or activation fails.
2. nmcli device connect<网卡名>: directly instructs the network card device itself to "find a way to connect to the internet." When NetworkManager detects that the network card has no bound configuration file, it automatically creates a default DHCP connection configuration in memory and activates it immediately, so the network card can connect instantly. |