NetworkManager connection priority - manage network profile priority in Linux.

Опубликовано: 29 Сентябрь 2024
на канале: Business Server Solutions
2,616
17

NetworkManager connection priority - manage network profile priority in Linux.
---
Manage multiple NetworkManager connections autoconnect and start up priority in Linux.

Configure which NetworkManager connection should be active after system reboot or which connection should be activated when current active connection will be deactivated.

First of all you have to ensure that connection is set to connect automatically.
Every connection is set to connect automatically by default.
---
You can double-check that connection is set to connect automatically with command:
nmcli c s (con_name) | grep autoconnect

If connection.autoconnect setting is set to "no" you can set it to "yes" with below command:
nmcli c mod (con_name) connection.autoconnect yes

To set autoconnect priority use command:
nmcli c mod (con_name) connection.autoconnect-priority (X)
where X represents priority number.

To review connection priority run command:
nmcli c s (con_name) | grep priority

Higher priority number means higher autoconnect priority so connection with highest priority number will be activated if connection.autoconnect is set to "yes" as well.

To list all NetworkManager connections configured on the server run:
nmcli c s

To list active NetworkManager connection run:
nmcli c s --active
NOTE: Only one NetworkManager connection can be active per one network interface. If you have multiple network interfaces more connections can be active but only one connection per one Network interface.

Review connection's IP addresses with nmcli connection show command:
nmcli c s con1 | grep -i address
nmcli c s con2 | grep -i address
nmcli c s con3 | grep -i address

Set autoconnect-priority for configured NetworkManager connections:
nmcli c mod con1 connection.autoconnect-priority 1
nmcli c mod con2 connection.autoconnect-priority 2
nmcli c mod con3 connection.autoconnect-priority 3

Review value of autoconnect-priority and also verify that autoconnect is set to "yes":
nmcli c s con1 | grep autoconnect
nmcli c s con2 | grep autoconnect
nmcli c s con3 | grep autoconnect

Reboot server:
shutdown -r now

After reboot - connection with highest priority will be active (con3 in our case).
nmcli c s --active
ip a

Deactivate NetworkManager connection with highest priority which is con3:
nmcli con down con3

NetworkManager connection with second highest priority will become active.
Review active NetworkManager connection:
nmcli c s --active
ip a

Deactivate NetworkManager connection with second highest priority which is con2:
nmcli con down con2

NetworkManager connection with lower priority will become active.
Review active NetworkManager connection:
nmcli c s --active
ip a

Add fourth NetworkManager connection:
nmcli con add con-name con4 type ethernet ifname eth0

This connection was set-up as "auto" - Automatic (Dynamic - DHCP) connection by default.
nmcli c s con4 | grep method

NetworkManager priority of newly added connection is automatically set to 0 by default and autoconnect is set to "yes" by default.
nmcli c s con4 | grep autoconnect

Activate new NetworkManager connection:
nmcli con up con4

Confirm that con4 NetworkManager connection is now active:
nmcli c s --active
ip a

Reboot server
shutdown -r now

Review active NetworkManager connection which is con3 because it has highest autoconnect-priority:
nmcli c s
nmcli c s --active
ip a

Related Video Tutorials:
RHCSA Fast Track course:
Reset forgotten root password in Redhat 7:
   • Reset forgotten root password in Redh...  

Network Interface naming convention in Red Hat 7:
   • Network Interface naming convention i...  

Setting up network without NetworkManager in Redhat 7:
   • Setting up network without NetworkMan...  

Setting up network using NetworkManager and network scripts in Redhat 7:
   • Setting up network using NetworkManag...  

Setting up network using a NetworkManager text user interface (nmtui) in Red Hat 7 - EASY!!!
   • Setting up network using a NetworkMan...  

Setting up network in Red Hat 7 in less than a minute - QUICK & EASY!!!
   • Setting up network in Red Hat 7 in le...  

Setting up network using a NetworkManager command line interface (nmcli) in Red Hat 7
   • Setting up network using a NetworkMan...  

nmcli cheat! Setting up network using nmcli in Red Hat 7 in less than a 30 seconds - QUICK & EASY!!!
   • nmcli cheat! Setting up network using...  

Setting up network using a NetworkManager connection editor GUI tool in Red Hat 7 - EASY!!!
   • Setting up network using a NetworkMan...  

The Complete Beginners Guide to Linux Network Configuration - GUI & Easy!
   • Complete Beginners Guide to Linux Net...  

Shrink ext2 ext3 and ext4 file system and reduce the size of a logical volume with only one command.
   • Shrink ext2 ext3 and ext4 file system...  

Complete guide to file system shrinking and reducing the size of the underlying logical volume.
   • Complete guide to file system shrinki...  

Other related video tutorials:
Calculate netmask, network and broadcast address - EASY!:
   • Calculate netmask, network and broadc...  

NetworkManager connection priority - manage network profile priority in Linux:
   • NetworkManager connection priority - ...