All Products
Search
Document Center

Alibaba Cloud Linux:Common NetworkManager operations

Last Updated:Feb 27, 2026

NetworkManager manages network interface controller (NIC) configurations and connection status on Alibaba Cloud Linux. It detects available networks, switches connections on demand, and provides the nmcli command-line tool to configure IP addresses, gateways, DNS settings, routes, and more.

Prerequisites

Before you begin, make sure that:

  • Your instance runs Alibaba Cloud Linux 3

  • You have sudo privileges

Tip: For an interactive text-based interface, use nmtui instead of nmcli.

Connection-based and device-based configuration

NetworkManager supports two configuration modes:

ModePersistenceWhen changes take effectUse case
Connection-basedPersistent across rebootsAfter you activate the connectionPermanent network changes
Device-basedLost after rebootImmediatelyTemporary changes for testing or troubleshooting

Multi-value property syntax

For properties that accept multiple values (addresses, routes, routing rules), use the following prefixes:

PrefixActionExample
+Add a value+ipv4.addresses 192.0.2.10/24
_(none)_Replace all valuesipv4.addresses 192.0.2.10/24
-Remove a specific value-ipv4.addresses 192.0.2.10/24

Connection-based operations

Connection-based changes are persistent. After each modify command, activate the connection to apply changes.

List connections

List all connection profiles with their associated configuration files:

nmcli -f NAME,FILENAME,TYPE,DEVICE connection

Sample output:

NAME   FILENAME                                                  TYPE      DEVICE
eth0   /etc/NetworkManager/system-connections/eth0.nmconnection   ethernet  eth0

Use the value from the NAME column as <connection-name> in the commands below.

View connection details

nmcli connection show "<connection-name>"

Activate and deactivate connections

Activate a connection:

sudo nmcli connection up "<connection-name>"

Deactivate a connection:

sudo nmcli connection down "<connection-name>"

Change MTU

  1. Set a new MTU value: Replace <mtu-value> with the desired MTU, for example, 9000 for jumbo frames.

    sudo nmcli connection modify "<connection-name>" 802-3-ethernet.mtu <mtu-value>
  2. Activate the connection to apply the change:

    sudo nmcli connection up "<connection-name>"
  3. Verify the new MTU:

    ip link show "<device-name>"

Add, replace, or remove an IP address

  1. Modify the IP address:

    # Add an IP address
    sudo nmcli connection modify "<connection-name>" +ipv4.addresses 192.0.2.10/24
    
    # Replace all IP addresses
    sudo nmcli connection modify "<connection-name>" ipv4.addresses 192.0.2.20/24
    
    # Remove a specific IP address
    sudo nmcli connection modify "<connection-name>" -ipv4.addresses 192.0.2.10/24
  2. Activate the connection:

    sudo nmcli connection up "<connection-name>"
  3. Verify:

    ip address show "<device-name>"

Change MAC address

  1. Set a cloned MAC address: Replace <new-mac-address> with the MAC address in colon-separated format, for example, AA:BB:CC:DD:EE:FF.

    sudo nmcli connection modify "<connection-name>" 802-3-ethernet.cloned-mac-address <new-mac-address>
  2. Activate the connection:

    sudo nmcli connection up "<connection-name>"

Add, replace, or remove a route

  1. Modify the route: The format is <destination> <gateway>. This example routes traffic for 198.51.100.0/24 through gateway 192.0.2.1.

    # Add a route
    sudo nmcli connection modify "<connection-name>" +ipv4.routes "198.51.100.0/24 192.0.2.1"
    
    # Replace all routes
    sudo nmcli connection modify "<connection-name>" ipv4.routes "198.51.100.0/24 192.0.2.1"
    
    # Remove a specific route
    sudo nmcli connection modify "<connection-name>" -ipv4.routes "198.51.100.0/24 192.0.2.1"
  2. Activate the connection:

    sudo nmcli connection up "<connection-name>"
  3. Verify:

    ip route show

Add, replace, or remove a routing rule

  1. Modify the routing rule:

    # Add a routing rule
    sudo nmcli connection modify "<connection-name>" +ipv4.routing-rules "priority 100 from 192.0.2.0/24 table 100"
    
    # Replace all routing rules
    sudo nmcli connection modify "<connection-name>" ipv4.routing-rules "priority 100 from 192.0.2.0/24 table 100"
    
    # Remove a specific routing rule
    sudo nmcli connection modify "<connection-name>" -ipv4.routing-rules "priority 100 from 192.0.2.0/24 table 100"
  2. Activate the connection:

    sudo nmcli connection up "<connection-name>"
  3. Verify:

    ip rule show

Device-based operations

Device-based changes take effect immediately but are lost after reboot. Use this mode for temporary configurations or quick testing.

View device status

nmcli device status

Sample output:

DEVICE  TYPE      STATE      CONNECTION
eth0    ethernet  connected  eth0
lo      loopback  unmanaged  --

Use the value from the DEVICE column as <device-name> in the commands below.

Enable or disable a NIC

Enable a NIC:

sudo nmcli device up "<device-name>"

Disable a NIC:

sudo nmcli device down "<device-name>"

Change MTU

sudo nmcli device modify "<device-name>" 802-3-ethernet.mtu <mtu-value>

Add, replace, or remove an IP address

# Add an IP address
sudo nmcli device modify "<device-name>" +ipv4.addresses 192.0.2.10/24

# Replace all IP addresses
sudo nmcli device modify "<device-name>" ipv4.addresses 192.0.2.10/24

# Remove a specific IP address
sudo nmcli device modify "<device-name>" -ipv4.addresses 192.0.2.10/24

Add, replace, or remove a route

# Add a route
sudo nmcli device modify "<device-name>" +ipv4.routes "198.51.100.0/24 192.0.2.1"

# Replace all routes
sudo nmcli device modify "<device-name>" ipv4.routes "198.51.100.0/24 192.0.2.1"

# Remove a specific route
sudo nmcli device modify "<device-name>" -ipv4.routes "198.51.100.0/24 192.0.2.1"

Add, replace, or remove a routing rule

# Add a routing rule
sudo nmcli device modify "<device-name>" +ipv4.routing-rules "priority 100 from 192.0.2.0/24 table 100"

# Replace all routing rules
sudo nmcli device modify "<device-name>" ipv4.routing-rules "priority 100 from 192.0.2.0/24 table 100"

# Remove a specific routing rule
sudo nmcli device modify "<device-name>" -ipv4.routing-rules "priority 100 from 192.0.2.0/24 table 100"

Monitor network status

Monitor real-time network events such as connection state changes and device status updates:

nmcli monitor

Press Ctrl+C to stop monitoring.

Related topics