Table of Contents

nmcli (NetworkManager CLI)

Quick Commands

View current connections:

nmcli connection show

View device information from all devices:

nmcli device show

Add new interface with static IP

First get the name of the interface:

ip a

Then add a new connection:

nmcli connection add con-name <name-of-connection> ifname <interface-name> type ethernet

This can then look like this: nmcli connection add con-name Connection2 ifname ens19 type ethernet

Enable auto connection:

nmcli connection modify <name-of-connection> connection.autoconnect yes

Set IP:

nmcli connection modify <name-of-connection> ipv4.addresses <ip-with-netmask>

This can then look like this: nmcli connection modify Connection1 ipv4.addresses 192.168.0.2/24

Set method to static:

nmcli connection modify <name-of-connection> ipv4.method static

Set default gateway:

nmcli connection modify <name-of-connection> ipv4.gateway <gateway-ip>

Set DNS server:

nmcli connection modify <name-of-connection> ipv4.dns "<dns-ip>"

Then verify everything was saved correctly:

nmcli device show

If everything is correct, start the new connection:

nmcli connection up <name-of-connection>