nmcli

nmcli

nmcli is a command line tool for managing network interfaces via Network Manager. You can configure interfaces as well as view their status. When making changes to a ‘connection’ with nmcli you are effectively overwriting the connection files store in /etc/sysconfig/network-scripts

For example the following command will overwrite the ONBOOT setting in /etc/sysconfig/network-scripts/ifcfg-eno1

nmcli connection modify eno1 connection.autoconnect yes

I’ve noticed a couple of interesting things about nmcli and decided to make note of them here:

  • When changing the connection.id parameter of a connection using nmcli the actual file name in /etc/sysconfig/networking-scripts is not changed. For example if you have a connection file named ‘eno1’ – /etc/sysconfig/networking-scripts/ifcfg-eno1 and you run the following command:nmcli con mod eno1 connection.id eno1-static (I’m using short hand, con for ‘connection’ and mod ‘modify’)the actual file name /etc/sysconfig/networking-scripts/ifcfg-eno1 is not changed to ifcfg-eno1-static. However, the NAME parameter inside of ifcfg-eno1 is changed to eno1-static. The connection.id parameter is referenced in different ways when using nmcli. For example the output of the command:nmcli connection

    this command displays your networking connections and what devices they are associated with. There is a column called “NAME” in the output that is referencing whatever has been set as the connection.id parameter
nmcli-connection-output

Output of command: nmcli connection

  • I also noticed that if you have multiple connections all with the same connection.autoconnect parameter set to yes then the one that will be chosen by the system to use as the default connection will be whichever one was created first.
  • If you manually change the /etc/sysconfig/network-scripts files you will need to restart Network Manager for the changes to show up in nmclisudo systemctl restart NetworkManager
  • When ssh’d into a server you have to sudo to run nmcli commands that alter a connection. When sitting at and logged directly into the terminal I did not need sudo privileges to make change to interface records.
  • If you delete a connection with nmcli while being ssh’d into a server it is possible to not loose your connection if you have another connection configured that can take over. It is possible that the process happens so fast that ssh has not had time to loose the connection. I can’t say for sure that it would 100% work this way every time but at least it did during my testing.

 

 

 

 

Elliot Holden
elliot@elliotmywebguy.com

A dope web developer!

1 Comment
  • elliotholden
    Posted at 17:19h, 04 December Reply

    Nothing like being the first one to comment on a post:-)

Post A Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.