All Products
Search
Document Center

Alibaba Cloud Linux:Configure NetworkManager not to manage secondary NICs to prevent network configuration conflicts

Last Updated:Sep 10, 2024

By default, NetworkManager is used to manage all Ethernet network interface controllers (NICs) in a simple and easy manner in Alibaba Cloud Linux 3. However, if you use NetworkManager in specific scenarios, such as containerized scenarios, to manage all Ethernet NICs in Alibaba Cloud Linux 3, the host network configuration may conflict with the container network configuration. To prevent the preceding issue, you can configure NetworkManager to manage primary NICs, such as eth0, but not secondary NICs, such as eth1.

Limits

This topic is applicable only to Elastic Compute Service (ECS) instances that run Alibaba Cloud Linux 3.

Check the status of NICs

Run the following command to check the status of NICs:

nmcli device status

The following command output is returned, which indicates that the eth0 and eth1 NICs are managed by NetworkManager, but the lo NIC is not managed by NetworkManager.

image

Configure NetworkManager not to manage secondary NICs

You can use one of the following methods to configure NetworkManager not to manage secondary NICs. In the following examples, NetworkManager is configured not to manage the eth1 secondary NIC.

Method 1: Modify the unmanaged.conf file

The changes that you make by using this method immediately take effect and persist. The changes remain in effect even after you restart the operating system.

Note

The unmanaged.conf file persists when you upgrade the NetworkManager Red Hat Package Manager (RPM) package or when you delete and then re-install the package.

  1. Run the following command to open the unmanaged.conf file:

    sudo vim /etc/NetworkManager/conf.d/unmanaged.conf
  2. Press the I key to enter Insert mode. Add the following content to the file:

    [keyfile]
    unmanaged-devices=interface-name:eth1
  3. Press the Esc key, enter :wq, and then press the Enter key to save and close the file.

  4. Run the following command for the changes to take effect:

    sudo systemctl restart NetworkManager
  5. Run the following command to check whether the changes have taken effect:

    nmcli device status

Method 2: Run the nmcli command

The changes that you make by using this method immediately take effect but do not persist.

  1. Run the following command to change the status of the eth1 secondary NIC to unmanaged:

    sudo nmcli device set eth1 managed no
  2. Run the following command to check whether the eth1 secondary NIC is in the unmanaged state:

    nmcli device status

Method 3: Modify the ifcfg-eth1file

The changes that you make by using this method immediately take effect but do not persist.

  1. Run the following command to open the ifcfg-eth1 file:

    sudo vim /etc/sysconfig/network-scripts/ifcfg-eth1
  2. Press the I key to enter Insert mode. Append the following content to the end of the file:

    NM_CONTROLLED=no
  3. Press the Esc key, enter :wq, and then press the Enter key to save and close the file.

  4. Run the following command for the changes to take effect:

    sudo systemctl restart NetworkManager
  5. Run the following command to check whether the changes have taken effect:

    nmcli device status