Wednesday, July 3, 2024
HomeNetworkingConfigure Network NIC Teaming on Rocky Linux 8|AlmaLinux 8

Configure Network NIC Teaming on Rocky Linux 8|AlmaLinux 8

Network NIC Teaming can be described as the aggregation of multiple network links into a single logical link. This is mainly done to boost redundancy and bandwidth. The team interface created provides an alternative link when the one physical link is down thus providing an uninterrupted connection to your server.

There are a couple of concepts you might need to understand before we proceed:

  • teamd – the nic teaming daemon that uses the libteam library to communicate with team devices via the Linux kernel.
  • teamdctl – a utility that allows one control teamd instances. Using it, you can check and change the port status, as well as switch between backup and active states.
  • runners – units written in JSON format to implement of various NIC teaming concepts. There are several runners(Team running modes) that include:
    • broadcast – here, data is transmitted accross all interfaces.
    • round-robin – data is transmitted over all ports in turn
    • active-backup – one port or link is used at a time while others are kept as a backup
    • lacp – this one implements the 802.3ad Link Aggregation Control Protocol
    • loadbalance – With active Tx load balancing and BPF-based Tx port selectors. Traffic is transmitted across all NICs.

This guide offers a detailed illustration of how to configure Network NIC Teaming on Rocky Linux 8| Alma Linux 8.

Setup Pre-requisites

For this guide, you need the following:

  • A user with sudo access.
  • Two/more interface adapters attached to your system.

Step 1 – Install the Teaming Daemon on Rocky Linux 8| Alma Linux 8

The teaming daemon is available in the default Rocky Linux 8| Alma Linux 8 repositories and can be installed as below.

sudo dnf -y install teamd

Once installed, check the installed version.

$ rpm -qi teamd
Name        : teamd
Version     : 1.31
Release     : 2.el8
Architecture: x86_64
Install Date: Wed 29 Sep 2021 04:01:14 AM EDT
Group       : System Environment/Daemons
Size        : 282950
License     : LGPLv2+
Signature   : RSA/SHA256, Sun 11 Apr 2021 11:14:13 PM EDT, Key ID 15af5dac6d745a60
Source RPM  : libteam-1.31-2.el8.src.rpm
Build Date  : Sun 14 Mar 2021 06:12:27 PM EDT
Build Host  : ord1-prod-x86build003.svc.aws.rockylinux.org
Relocations : (not relocatable)
Packager    : [email protected]
Vendor      : Rocky
URL         : http://www.libteam.org
Summary     : Team network device control daemon
Description :
The teamd package contains team network device control daemon.

Step 2 – Configure NIC Teaming on Rocky Linux 8| Alma Linux 8

For this guide, we will cover two methods on how to configure NIC Teaming on Rocky Linux 8| Alma Linux 8 namely:

  • Using NMCLI
  • Using Ansible system roles
  • Using nmstatectl

Method 1 – Configure NIC Teaming on Rocky Linux 8| Alma Linux 8 using NMCLI

It is possible to use Network Manager’s nmcli tool to configure bonds. First, check the network interfaces on your system.

nmcli device status

Sample output:

Configure Network NIC Teaming on Rocky Linux Alma Linux 4

From the above output, there are two interface devices enp1s0 and enp9s0 connected to my system. You can as well gather more information using the command below.

nmcli connection show

Sample output:

Configure Network NIC Teaming on Rocky Linux Alma Linux 4 1

Disconnect the two devices using the UUID as below.

sudo nmcli connection delete 93a375cc-3c29-4a52-9fb9-0f6940ea4c2a
sudo nmcli connection delete 6c574fa3-98eb-40f1-a463-6b9271397d55

Once deleted, the devices should be disconnected as below.

Configure Network NIC Teaming on Rocky Linux Alma Linux 5

Now let us create a team with the name team1 with a preferred runner say active-backup where one port or link is used at a time while others are kept as a backup. You can also use any of the runners broadcast, lacp, round-robin and random.

sudo nmcli connection add type team con-name team1 ifname team1 config '{"runner": {"name": "activebackup"}}'

Show the created team.

$ nmcli connection show team1
connection.id:                          team1
connection.uuid:                        dad0b991-fd00-45ca-9e3b-8f7843498f47
connection.stable-id:                   --
connection.type:                        team
connection.interface-name:              team1
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.autoconnect-retries:         -1 (default)
connection.multi-connect:               0 (default)
connection.auth-retries:                -1
connection.timestamp:                   0
connection.read-only:                   no
connection.permissions:                 --
connection.zone:                        --
connection.master:                      --
connection.slave-type:                  --
connection.autoconnect-slaves:          -1 (default)
connection.secondaries:                 --
......

Now set the IP address, DNS, and auto-connection for the new team.

sudo nmcli con mod team1 ipv4.addresses 192.168.205.100/24
sudo nmcli con mod team1 ipv4.gateway 192.168.205.1
sudo nmcli con mod team1 ipv4.dns 8.8.8.8
sudo nmcli con mod team1 ipv4.method manual
sudo nmcli con mod team1 connection.autoconnect yes

Now add the slave networks and link them to the team.

sudo nmcli con add type team-slave con-name team1-slave0 ifname enp1s0 master team1
sudo nmcli con add type team-slave con-name team1-slave1 ifname enp9s0 master team1

Once added, check the status of the links.

$ nmcli connection show
NAME          UUID                                  TYPE      DEVICE  
enp10so       77ae630c-8940-4b6d-9ae2-09f358296b41  ethernet  enp10s0 
team1         dad0b991-fd00-45ca-9e3b-8f7843498f47  team      team1   
virbr0        2219ff25-c5f7-486c-9d2d-7a585be22cfe  bridge    virbr0  
team1-slave0  9cdf0f6f-d6d4-45e5-bb8a-8ff7365fcd7a  ethernet  enp1s0  
team1-slave1  67a57ddf-4595-4be2-b6ae-f5b481083d47  ethernet  enp9s0  

For the changes made to apply, restart the team.

$ sudo nmcli connection down team1 && sudo nmcli connection up team1
Connection 'team1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/9)

View the status of the team interface.

ip addr show dev team1

Output:

Configure Network NIC Teaming on Rocky Linux Alma Linux 6

You can as well use the teamdctltool to view more information.

sudo teamdctl team1 state

Sample output:

Configure Network NIC Teaming on Rocky Linux Alma Linux 7

Test the Team functionality.

With the active backup runner used, we want to see if it is working correctly. So we will try and bring down the active port enp1s0

sudo nmcli device disconnect enp1s0

Check the status of the team.

sudo teamdctl team1 state

Sample output:

Configure Network NIC Teaming on Rocky Linux Alma Linux 8

From the above output, we see the active port switched to enp9s0 and that proves that the active backup runner is working perfectly.

Delete Team with nmcli

If at some point you want to delete a team, worry not. This is so easy and can be accomplished using the nmcli utility with the steps below:

Show the connection details.

$ nmcli connection show 
NAME          UUID                                  TYPE      DEVICE  
enp10so       77ae630c-8940-4b6d-9ae2-09f358296b41  ethernet  enp10s0 
team1         dad0b991-fd00-45ca-9e3b-8f7843498f47  team      team1   
virbr0        2219ff25-c5f7-486c-9d2d-7a585be22cfe  bridge    virbr0  
team1-slave1  67a57ddf-4595-4be2-b6ae-f5b481083d47  ethernet  enp9s0  
team1-slave0  9cdf0f6f-d6d4-45e5-bb8a-8ff7365fcd7a  ethernet  --      

Deactivate the team you intend to delete.

sudo nmcli connection down team1

Now delete slaves on the team.

$ sudo nmcli connection delete team1-slave0 team1-slave1
Connection 'team1-slave0' (9cdf0f6f-d6d4-45e5-bb8a-8ff7365fcd7a) successfully deleted.
Connection 'team1-slave1' (67a57ddf-4595-4be2-b6ae-f5b481083d47) successfully deleted.

Now delete the team:

$ sudo nmcli connection delete team1
Connection 'team1' (dad0b991-fd00-45ca-9e3b-8f7843498f47) successfully deleted.

Verify if the team has been deleted successfully.

$ nmcli connection show 
NAME     UUID                                  TYPE      DEVICE  
enp10so  77ae630c-8940-4b6d-9ae2-09f358296b41  ethernet  enp10s0 
virbr0   2219ff25-c5f7-486c-9d2d-7a585be22cfe  bridge    virbr0  

Method 2 – Create a Network Team On Rocky Linux 8| Alma Linux 8 Using Ansible system roles.

This is yet another method to create a network bond using ansible. I assume that you already have Ansible is installed and configured on your system.

Install the rhel-system-roles package.

sudo yum install rhel-system-roles

Add the host on which you want to configure the team in the Inventory file.

$ sudo vi /etc/ansible/hosts
192.168.205.2

You may also be needed to add SSH keys of this managed host to your control node.

Now create the playbook YAML for the network team as below.

vi ~/bond-ethernet.yml

In the file, add the lines below.

---
- name: Configure a network bond that uses two Ethernet ports
  hosts: 192.168.205.2
  become: true
  tasks:
  - include_role:
      name: rhel-system-roles.network

    vars:
      network_connections:
        # Define the bond profile
        - name: bond0
          type: bond
          interface_name: bond0
          ip:
            address:
              - "192.168.205.100/24"
            gateway4: 192.168.205.1
            dns:
              - 8.8.8.8
            dns_search:
              - example.com
          bond:
            mode: active-backup
          state: up

        # Add an Ethernet profile to the bond
        - name: bond0-port1
          interface_name: enp9s0
          type: ethernet
          controller: bond0
          state: up

        # Add a second Ethernet profile to the bond
        - name: bond0-port2
          interface_name: enp10s0
          type: ethernet
          controller: bond0
          state: up

Here, I have configured a network team using two devices enp9s0 and enp10s0, set the Ip address for the bond as 192.168.205.100 with the gateway 192.168.205.1.

Now with the right details set, run the playbook as the root user of the managed host.

ansible-playbook -u root ~/bond-ethernet.yml

Sample output:

Configure Network NIC Teaming on Rocky Linux Alma Linux

Verify the bond status.

sudo cat /proc/net/bonding/bond0

Sample Output:

Configure Network NIC Teaming on Rocky Linux Alma Linux 1

Method 3 – Create a Network Team On Rocky Linux 8| Alma Linux 8 Using nmstatectl

With this method, ensure that the nmstate package is installed.

sudo yum install nmstate

Then create a YAML file as below.

vi ~/create-bond.yml

In the file, set the Team preferences as below.

---
interfaces:
- name: bond0
  type: bond
  state: up
  ipv4:
    enabled: true
    address:
    - ip: 192.168.205.100
      prefix-length: 24
    dhcp: false
  link-aggregation:
    mode: active-backup
    port:
    - enp9s0
    - enp10s0
- name: enp9s0
  type: ethernet
  state: up
- name: enp10s0
  type: ethernet
  state: up

routes:
  config:
  - destination: 0.0.0.0/0
    next-hop-address: 192.168.205.1
    next-hop-interface: bond0

dns-resolver:
  config:
    search:
    - example.com
    server:
    - 8.8.8.8

In the file, replace:

  • ip: 192.168.205.100 with the preferred network bond
  • next-hop-address: 192.168.205.1 with the Pv4 default gateway

Save the file and apply the settings to your system.

sudo nmstatectl apply ~/create-bond.yml

Sample output:

Configure Network NIC Teaming on Rocky Linux Alma Linux 2

Verify if the bond exists.

$ sudo nmcli device status
DEVICE      TYPE      STATE                   CONNECTION 
enp1s0      ethernet  connected               enp1s0     
bond0       bond      connected               bond0      
virbr0      bridge    connected (externally)  virbr0     
enp10s0     ethernet  connected               enp10s0    
enp9s0      ethernet  connected               enp9s0     
lo          loopback  unmanaged               --         
virbr0-nic  tun       unmanaged               --       

You can also view detailed information about the bond.

sudo nmcli connection show bond0

Output:

Configure Network NIC Teaming on Rocky Linux Alma Linux 3

Conclusion

That is it!

We have triumphantly configured Network NIC Teaming on Rocky Linux 8| Alma Linux 8 using NMCLI, ansible system roles, and nmstatectl. I hope this was significant to you.

See more.

Calisto Chipfumbu
Calisto Chipfumbuhttp://cchipfumbu@gmail.com
I have 5 years' worth of experience in the IT industry, primarily focused on Linux and Database administration. In those years, apart from learning significant technical knowledge, I also became comfortable working in a professional team and adapting to my environment, as I switched through 3 roles in that time.
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments