View current connections:

nmcli connection show

View device information from all devices:

nmcli device show

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

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>
  • linux/debian/nmcli.txt
  • Last modified: 2024/04/09 22:25
  • by Zyzonix