How to create NIC teaming or bonding in Linux RHEL 8/RHEL 9

by Jay

NIC teaming and bonding are techniques used to combine multiple network interface controllers (NICs) into a single logical interface in order to provide increased network bandwidth, redundancy, and/or load balancing.

NIC teaming, also known as NIC aggregation or link aggregation, involves combining two or more physical NICs into a single logical interface, typically through the use of specialized software or hardware. This allows the network traffic to be distributed across multiple NICs, which can help to increase network bandwidth, improve network reliability and provide redundancy in case of a NIC failure.

 NIC Teaming

Bonding, on the other hand, involves creating a virtual network interface by aggregating two or more NICs at the data link layer. Unlike NIC teaming, bonding is typically implemented at the operating system level and doesn’t require any specialized hardware. Bonding can be used for load balancing and fault tolerance, and it supports a variety of bonding modes such as round-robin, active-backup, and adaptive load balancing.

Both NIC teaming and bonding are useful techniques for improving network performance, reliability, and availability. However, they require careful planning and configuration in order to ensure that they are set up correctly and functioning as intended.

Teaming Terminologies


Before we begin to configuration NIC teaming lets understand the teaming terminologies

Teamd: Teamd is a daemon that manages network teaming interfaces. It provides a user space interface for teaming multiple network interfaces and presenting them as a single virtual interface to the Linux kernel.

Teamdctl: Teamdctl is a command-line tool used to manage the teamd daemon. It allows you to create, modify, and delete network teaming interfaces, as well as query and monitor their status.

Runner: Runner is a type of teaming mode supported by teamd. It is a load-balancing mode that distributes traffic across the team member interfaces based on the destination MAC address. This helps improve network throughput and reduce latency by utilizing all available network paths.

In this tutorials we will be configuring NIC teaming using the active-backup mode. This means One link will be active at a time and other will be standby as a backup

Without doing any further delay lets start the configuration

NIC Teaming configuration in RHEL 7, RHEL 8 and RHEL 9 or CenOS, RockyLinux or Alma Linux


Install the teamd Daemon in CentOS if its not already installed


Check if teamd is installed or not, it should be installed by default on the system

[root@TechArticles ~]# dnf list installed teamd
Installed Packages
teamd.x86_64                        1.31-2.el8                         @anaconda

If teamd not already installed, Install it by

[root@TechArticles ~]# dnf install teamd -y

Next step to Configure NIC Teaming


We’ll utilise the useful nmcli tool, which can also be used to manage the NetworkManager service. I’m planning to bond or team two NIC cards to establish a logical team interface: enp0s8 and enp0s9. Please Note: This may not be the situation in your circumstance.

Check the device status by running below command

[root@TechArticles ~]# nmcli device status
DEVICE  TYPE      STATE                   CONNECTION
enp0s3  ethernet  connected               enp0s3
enp0s8  ethernet  connected               ethernet-enp0s8
enp0s9  ethernet  connected               ethernet-enp0s9
virbr0  bridge    connected (externally)  virbr0
lo      loopback  unmanaged               --

To check the above two networks are available run the below command

[root@TechArticles ~]# nmcli connection show
NAME             UUID                                  TYPE      DEVICE
enp0s3           b972dea7-b72d-4e48-a838-bda20615e189  ethernet  enp0s3
ethernet-enp0s8  7d533e83-a610-4436-a66e-c1c31c795b03  ethernet  enp0s8
ethernet-enp0s9  4265df88-53fc-4585-87ca-e3a031cfa8b6  ethernet  enp0s9
virbr0           37e3e593-87fe-4f80-a8e0-a63cc6598da8  bridge    virbr0

We will delete the existing network interfaces in order to create a network teaming connection or interface that will serve as our logical link. Following that, we will establish slave interfaces from the removed interfaces and associate them with the teaming link.

To erase the links, use their individual UUIDs and run the following commands:

[root@TechArticles ~]# nmcli connection delete 7d533e83-a610-4436-a66e-c1c31c795b03
Connection 'ethernet-enp0s8' (7d533e83-a610-4436-a66e-c1c31c795b03) successfully deleted.
[root@TechArticles ~]# nmcli connection delete 4265df88-53fc-4585-87ca-e3a031cfa8b6
Connection 'ethernet-enp0s9' (4265df88-53fc-4585-87ca-e3a031cfa8b6) successfully deleted.

Now reheck the device status it should be disconnected

[root@TechArticles ~]# nmcli device status
DEVICE  TYPE      STATE                   CONNECTION
enp0s3  ethernet  connected               enp0s3
virbr0  bridge    connected (externally)  virbr0
enp0s8  ethernet  disconnected            --
enp0s9  ethernet  disconnected            --
lo      loopback  unmanaged               --

Next Add the team0 connection by command # nmcli connection add type team con-name team0 ifname team0 config '{"runner": {"name": "activebackup"}}'

[root@TechArticles ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner": {"name": "activebackup"}}'

Connection 'team0' (85b00462-deb8-4f26-ada8-233c9b999732) successfully added.
[root@TechArticles ~]#

Now you can check details assigned to the team0 interface run the # nmcli connection show team0 command:

[root@TechArticles ~]# nmcli connection show team0
connection.id:                          team0
connection.uuid:                        85b00462-deb8-4f26-ada8-233c9b999732
connection.stable-id:                   --
connection.type:                        team
connection.interface-name:              team0
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.autoconnect-retries:         -1 (default)
connection.multi-connect:               0 (default)
connection.auth-retries:                -1
{..}

You can check the interface team0 status by running nmcli connection show command. Till now interface is created but we did not added our actuals interfaces enp0s8 and enp0s9.

[root@TechArticles ~]# nmcli connection show
NAME    UUID                                  TYPE      DEVICE
team0   85b00462-deb8-4f26-ada8-233c9b999732  team      team0
enp0s3  b972dea7-b72d-4e48-a838-bda20615e189  ethernet  enp0s3
virbr0  37e3e593-87fe-4f80-a8e0-a63cc6598da8  bridge    virbr0

Add the two NIC cards one by one to the above created connection by

# nmcli con add type team-slave con-name team0-slave0 ifname enp0s8 master team0
# nmcli con add type team-slave con-name team0-slave1 ifname enp0s9 master team0

Example:

[root@TechArticles ~]# nmcli con add type team-slave con-name team0-slave0 ifname enp0s8 master team0
Connection 'team0-slave0' (1925da41-85d8-4e34-84d2-9ef6564a3d70) successfully added.
[root@TechArticles ~]# nmcli con add type team-slave con-name team0-slave1 ifname enp0s9 master team0
Connection 'team0-slave1' (00f29fa7-d1c2-4bf8-a900-8400738aa131) successfully added.

Let’s configure the IP Address of interface team0 Please reach out to your network team for correct IP, SM and DNS for demonstration purpose I am using IP : 192.168.111.100, SM : 255.255.255.0, DG: 192.168.111.52 and DNS: 8.8.8.8, Please make sure you do not get any error while running below commands

# nmcli con mod team0 ipv4.addresses 192.168.111.100/24
# nmcli con mod team0 ipv4.gateway 192.168.111.52
# nmcli con mod team0 ipv4.dns 8.8.8.8
# nmcli con mod team0 ipv4.method manual
# nmcli con mod team0 connection.autoconnect yes

New check the status of connection by nmcli connection show command

[root@TechArticles ~]# nmcli connection show
NAME          UUID                                  TYPE      DEVICE
enp0s3        b972dea7-b72d-4e48-a838-bda20615e189  ethernet  enp0s3
team0         85b00462-deb8-4f26-ada8-233c9b999732  team      team0
virbr0        37e3e593-87fe-4f80-a8e0-a63cc6598da8  bridge    virbr0
team0-slave0  1925da41-85d8-4e34-84d2-9ef6564a3d70  ethernet  enp0s8
team0-slave1  00f29fa7-d1c2-4bf8-a900-8400738aa131  ethernet  enp0s9

Now try deactivating and reactivating the team link. This turns on the connection between the slave and team links.

# nmcli connection down team0 
# nmcli connection up team0

Now, Verifiy the connection link by running ip addr show dev team0 command.

[root@TechArticles ~]# ip addr show dev team0
7: team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 08:00:27:c2:15:90 brd ff:ff:ff:ff:ff:ff
    inet 192.168.111.100/24 brd 192.168.111.255 scope global noprefixroute team0
       valid_lft forever preferred_lft forever
    inet6 fe80::a547:95d4:83b7:5af0/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

As above output the link is operational and has the right IP addresses that we specified earlier.

To see the team0 connection up details by

# teamdctl team0 state

To check the connection communication by

# ping -I team0 <IP address>

To verify down the one NIC card in team0 by

# nmcli connection down enp0s8

To check the team0 NIC card up or down details

# teamdctl team0 state

Example: Check the highlighted interfaces are connected and up currently and running type is ActiveBackup and the current accitive port

[root@TechArticles ~]# teamdctl team0 state
setup:
  runner: activebackup
ports:
  enp0s8
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 1
  enp0s9
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
runner:
  active port: enp0s8

Lets Validate the teaming, Will down the enp0s8 port and check if the 2nd port is comming as active or not

[root@TechArticles ~]# nmcli device disconnect enp0s8
Device 'enp0s8' successfully disconnected.
[root@TechArticles ~]# teamdctl team0 state
setup:
  runner: activebackup
ports:
  enp0s9
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
runner:
  active port: enp0s9

Now you can see I have down the active port enp0s8, and the port enp0s9 is instantly active

Deleting the Teaming or Bnding


If you want to delete the already configured teaming, follow the below steps to do so

# nmcli connection down team0

Now delete the slave interfaces

nmcli connection delete team0-slave0 team0-slave1

In the last, delete the team0 interface

# nmcli connection delete team0

Example:

[root@TechArticles ~]# nmcli connection down team0
Connection 'team0' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/12)
[root@TechArticles ~]# nmcli connection delete team0-slave0 team0-slave1
Connection 'team0-slave0' (1925da41-85d8-4e34-84d2-9ef6564a3d70) successfully deleted.
Connection 'team0-slave1' (00f29fa7-d1c2-4bf8-a900-8400738aa131) successfully deleted.
[root@TechArticles ~]# nmcli connection delete team0
Connection 'team0' (85b00462-deb8-4f26-ada8-233c9b999732) successfully deleted.

What are the benefits of NIC Teaming?


(i) Load balancing

(ii) Fault Tolerance

(iii) Failover

Was this article of use to you? Post your insightful thoughts or recommendations in the comments section if you don’t find this article to be helpful or if you see any outdated information, a problem, or a typo to help this article better.

Related Posts

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.