Operations 6 min read

Mastering nmcli: Essential Commands to Manage Linux Network Interfaces

This guide presents a concise collection of common nmcli commands for displaying, modifying, adding, and controlling network interfaces on Linux, including how to rename interfaces, set static IPs, switch to DHCP, and restart connections with clear examples.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Mastering nmcli: Essential Commands to Manage Linux Network Interfaces

Common nmcli Commands

nmcli connection show

Display detailed information for all network connections. nmcli connection up <UUID|NAME> Activate the specified connection (identified by UUID or connection name). nmcli connection down <UUID|NAME> Deactivate the specified connection.

nmcli connection modify <UUID|NAME> ipv4.addresses <IP>/<netmask>

Set a static IPv4 address. netmask is the CIDR prefix length (e.g., 24 for 255.255.255.0 ).

nmcli connection modify <UUID|NAME> ipv4.gateway <gateway>

Define the IPv4 default gateway.

nmcli connection modify <UUID|NAME> ipv4.method manual

Switch the IPv4 method to manual (required for static addressing).

nmcli connection modify <UUID|NAME> ipv6.addresses <IP>/<netmask>

Set a static IPv6 address (CIDR notation).

nmcli connection modify <UUID|NAME> ipv6.gateway <gateway>

Define the IPv6 default gateway.

nmcli connection modify <UUID|NAME> ipv6.method manual

Switch the IPv6 method to manual.

nmcli connection modify <UUID|NAME> dns <DNS server>

Set DNS server(s) for the connection (comma‑separated for multiple servers).

nmcli connection modify <UUID|NAME> mtu <MTU value>

Adjust the Maximum Transmission Unit. nmcli connection show --active List all currently active connections. nmcli connection delete <UUID|NAME> Remove a connection profile.

Rename a Network Interface

nmcli connection modify uuid f136e0e3-5faf-4d2f-8c5f-4ce976585b30 con-name ens33
Rename interface
Rename interface

Add a New Interface

nmcli connection add type ethernet con-name ens37 ifname ens37
Add interface
Add interface

Activate or Deactivate an Interface

# Reload connection definitions (useful after editing files)
nmcli connection reload

# Bring the interface up
nmcli connection up ens33

# Bring the interface down
nmcli connection down ens33

# Restart the interface (down then up)
nmcli connection down ens33 && nmcli connection up ens33
Activate/deactivate interface
Activate/deactivate interface

Configure a Static IP Address

Set a fixed IPv4 address, gateway, and DNS for a specific interface.
# Replace placeholders with actual values
nmcli connection modify <interface|UUID> \
    ipv4.method manual \
    ipv4.addresses <IP>/<netmask> \
    ipv4.gateway <gateway> \
    ipv4.dns <DNS server>

# Example for interface <strong>ens37</strong>
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

# Apply the changes by restarting the interface
nmcli connection down ens37 && nmcli connection up ens37

# Verify the configuration
nmcli connection show ens37
Static IP configuration step 1
Static IP configuration step 1
Static IP configuration step 2
Static IP configuration step 2
Static IP configuration step 3
Static IP configuration step 3

Switch an Interface to DHCP

Remove any static IPv4 configuration and let the interface obtain its address automatically.
# Clear static IPv4 settings (empty strings remove the values)
nmcli connection modify ens37 ipv4.addresses "" ipv4.gateway "" ipv4.dns ""

# Change the method to automatic (DHCP)
nmcli connection modify ens37 ipv4.method auto

# Restart the interface to request a DHCP lease
nmcli connection down ens37 && nmcli connection up ens37
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CLInetworkLinuxnetwork managementnmclisystem-administration
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.