NetworkManager is a utility that is used to manage the configurations of network interface controllers (NICs) and the status of NIC connections. NetworkManager can automatically detect available networks and switch connections between the networks on demand. You can configure network settings, such as IP addresses, gateways, and DNS settings, based on your business requirements.
Limits
Operating system: Alibaba Cloud Linux 3.
Configure NICs
NetworkManager uses nmcli commands to query and manage NIC configurations based on connections and devices. You can configure NICs based on your actual scenario.
Connection-based configurations are persistent. You must activate connections to allow the configurations to take effect.
Device-based configurations are temporary. The configurations immediately take effect but become invalid after the system restarts.
Configure NICs based on connections
Replace the $name parameter with a value of the NAME field, as shown in the following figure.
Query information about the current connections and the configuration files that correspond to the connections.
nmcli -f NAME,FILENAME,TYPE,DEVICE connectionThe following figure shows the command output.

Query the details of a specific NIC connection.
nmcli connection show "$name"Manage NIC connections.
Activate a NIC connection.
sudo nmcli connection up "$name"Terminate a NIC connection.
sudo nmcli connection down "$name"
Change the MTU of a NIC connection.
Replace the
new_mtuparameter with a new MTU value.sudo nmcli connection modify "$name" 802-3-ethernet.mtu new_mtuRun the following command to allow the configuration to take effect:
sudo nmcli connection up "$name"
Manage IP addresses.
Assign an IP address to a NIC connection.
Replace the
new_ip_addrparameter with the IP address that you want to assign.sudo nmcli connection modify "$name" +ipv4.addresses new_ip_addrRun the following command to allow the configuration to take effect:
sudo nmcli connection up "$name"
Change the IP address of a NIC connection.
Replace the
new_ip_addrparameter with the new IP address that you want to assign.sudo nmcli connection modify "$name" ipv4.addresses new_ip_addrRun the following command to allow the configuration to take effect:
sudo nmcli connection up "$name"
Remove an IP address from a NIC connection.
Replace the
old_ip_addrparameter with the IP address that you want to remove.sudo nmcli connection modify "$name" -ipv4.addresses old_ip_addrRun the following command to allow the configuration to take effect:
sudo nmcli connection up "$name"
Change the MAC address of a NIC connection.
Replace the
new_mac_addrparameter with the new MAC address that you want to specify.sudo nmcli connection modify "$name" 802-3-ethernet.cloned-mac-address new_mac_addrRun the following command to allow the configuration to take effect:
sudo nmcli connection up "$name"
Manage routes.
Add a routing rule to a NIC connection.
Replace the
new_ruleparameter with the routing rule that you want to add.sudo nmcli connection modify "$name" +ipv4.routing-rules "new_rule"Update the routing rule of a NIC connection.
Replace the
new_ruleparameter with the new routing rule that you want to specify.sudo nmcli connection modify "$name" ipv4.routing-rules "new_rule"Remove a routing rule from a NIC connection.
Replace the
old_ruleparameter with the routing rule that you want to remove.sudo nmcli connection modify "$name" -ipv4.routing-rules "old_rule"Add a route to a NIC connection.
Replace the
new_routeparameter with the route that you want to add.sudo nmcli connection modify "$name" +ipv4.routes "new_route"Update the route of a NIC connection.
Replace the
new_routeparameter with the new route that you want to specify.nmcli connection modify "$name" ipv4.routes "new_route"Remove a route from a NIC connection.
Replace the
old_routeparameter with the route that you want to remove.sudo nmcli connection modify "$name" -ipv4.routes "old_route"
Configure NICs based on devices
Replace the $device parameter with a value of the DEVICE field, as shown in the following figure.
View the status of devices.
nmcli device statusThe following figure shows the command output.

Manage NIC connections.
Enable network connectivity for a NIC.
sudo nmcli device up "$device"Disable network connectivity for a NIC.
sudo nmcli device down "$device"
Change the MTU of a NIC.
Replace the
new_mtuparameter with a new MTU value.sudo nmcli device modify "$device" 802-3-ethernet.mtu new_mtuManage IP addresses.
Assign an IP address to a NIC.
Replace the
new_ip_addrparameter with the IP address that you want to assign.sudo nmcli device modify "$device" +ipv4.addresses new_ip_addrChange the IP address of a NIC.
Replace the
new_ip_addrparameter with the new IP address that you want to assign.sudo nmcli device modify "$device" ipv4.addresses new_ip_addrRemove an IP address from a NIC.
Replace the
old_ip_addrparameter with the IP address that you want to remove.sudo nmcli device modify "$device" -ipv4.addresses old_ip_addr
Manage routes.
Add a routing rule to a NIC.
Replace the
new_ruleparameter with the routing rule that you want to add.sudo nmcli device modify "$device" +ipv4.routing-rules "new_rule"Update the routing rule of a NIC.
Replace the
new_ruleparameter with the new routing rule that you want to specify.sudo nmcli device modify "$device" ipv4.routing-rules "new_rule"Remove a routing rule from a NIC.
Replace the
old_ruleparameter with the routing rule that you want to remove.sudo nmcli device modify "$device" -ipv4.routing-rules "old_rule"Add a route to a NIC.
Replace the
new_routeparameter with the route that you want to add.sudo nmcli device modify "$device" +ipv4.routes "new_route"Update the route of a NIC.
Replace the
new_routeparameter with the new route that you want to specify.sudo nmcli device modify "$device" ipv4.routes "new_route"Remove a route from a NIC.
Replace the
old_routeparameter with the route that you want to remove.sudo nmcli device modify "$device" -ipv4.routes "old_route"
Monitor networks
Monitor the status of networks.
nmcli monitorReferences
For information about source address-based routing, see Configure policy-based routes to direct traffic based on source IP addresses.
For information about how to configure NetworkManager to not manage secondary NICs, see Configure NetworkManager to not manage secondary NICs to prevent network configuration conflicts.
For information about how to configure hostnames, see Specify a hostname.
For information about how to create a dummy interface, see Create a dummy interface.
For information about the /etc/resolv.conf file, see Enable manual management for the /etc/resolv.conf file.