Linux: Set a static/fixed IP with Network Manager Cli


most of the Linux Distributions uses the NetworkManager to configure network connections.

Sometimes it is necessary to set a static IP address, i.e. if no DHCP Server is available on the network or you want to setup a peer to peer connection between the computers.

List connections

root@debdev ~ # nmcli con
NAME                UUID                                  TYPE      DEVICE
Wired connection 1  fac58792-304a-b3dd-88ad-b689ba1495b2  ethernet  eth0

And set IP Address, DNS search domain, DNS server and default gateway

root@debdev ~ # nmcli con mod "Wired connection 1" \
  ipv4.addresses "" \
  ipv4.gateway "" \
  ipv4.dns "," \
  ipv4.dns-search "" \
  ipv4.method "manual"

Its also possible to edit the config file. The connection config are placed in /etc/NetworkManager/system-connections

root@debdev ~ # cd /etc/NetworkManager/system-connections
root@debdev ~ # ls -l 
-rw------- 1 root root 316 Jun  4 22:56 'Wired connection 1'

Edit the IPv4 section. This also describes how to set a static route



Advertisment to support

One thought on “Linux: Set a static/fixed IP with Network Manager Cli”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.