Mastering nmcli: Essential Commands to Manage Linux Network Interfaces
This guide presents the most frequently used nmcli commands for displaying, modifying, adding, activating, deactivating, and configuring network interfaces on Linux, including examples for renaming interfaces, setting static IPs, and switching to DHCP mode.
Below are some common nmcli command options and usage:
connection show # Show detailed information of all network connections
connection up <UUID> # Activate a network connection
connection down <UUID> # Deactivate a network connection
connection modify <UUID> ipv4.addresses <IP>/<netmask> # Change IPv4 address
connection modify <UUID> ipv4.gateway <gateway> # Change IPv4 gateway
connection modify <UUID> ipv4.method manual # Set IPv4 method to manual
connection modify <UUID> ipv6.addresses <IP>/<netmask> # Change IPv6 address
connection modify <UUID> ipv6.gateway <gateway> # Change IPv6 gateway
connection modify <UUID> ipv6.method manual # Set IPv6 method to manual
connection modify <UUID> dns <DNS server> # Change DNS server
connection modify <UUID> mtu <MTU value> # Change MTU value
connection show --active # Show all active network connections
connection delete <UUID> # Delete a network interface1) Rename a network interface
nmcli c modify uuid f136e0e3-5faf-4d2f-8c5f-4ce976585b30 con-name ens332) Add a network interface
nmcli connection add type ethernet con-name ens37 ifname ens373) Activate or deactivate a network interface
nmcli connection reload # Reload interfaces
nmcli connection up ens33 # Activate interface ens33
nmcli connection down ens33 # Deactivate interface ens33
nmcli connection down ens33 && nmcli connection up ens33 # Restart interface ens334) Set static IP mode for an interface
Use nmcli to configure a static IP address.
nmcli connection modify <interface> ipv4.method manual ipv4.addresses <static_ip>/<netmask> ipv4.gateway <gateway_ip> ipv4.dns <dns_ip>
nmcli connection modify ens37 ipv4.method manual ipv4.addresses 192.168.70.133/24 ipv4.gateway 192.168.70.2 ipv4.dns 114.114.114.114
# Restart the interface to apply the configuration
nmcli c down ens37 && nmcli c up ens37
# View detailed information of the interface
nmcli connection show ens375) Switch an interface to DHCP mode
Set the eth0 interface to obtain an IP address via DHCP.
# Remove previously set static IP configuration
nmcli connection modify ens37 ipv4.addresses "" ipv4.gateway "" ipv4.dns ""
# Change the interface to DHCP mode
nmcli connection modify eth0 ipv4.method auto
# Restart the interface to apply changes
nmcli c down ens37 && nmcli c up ens37Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
MaGe Linux Operations
Founded in 2009, MaGe Education is a top Chinese high‑end IT training brand. Its graduates earn 12K+ RMB salaries, and the school has trained tens of thousands of students. It offers high‑pay courses in Linux cloud operations, Python full‑stack, automation, data analysis, AI, and Go high‑concurrency architecture. Thanks to quality courses and a solid reputation, it has talent partnerships with numerous internet firms.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
