How to create or configure NIC Teaming using nmcli (CentOS / RHEL 7/8)


Network, How To, Linux

In this article I will share step by step guide to configure NIC teaming or Network Teaming using nmcli (NetworkManager) (validated on RHEL and CentOS 7 and 8) with various examples.

How to create or configure NIC Teaming using nmcli (CentOS / RHEL 7/8)

 

Red Hat Enterprise Linux 7 implements network teaming with a small kernel driver and a user-space daemon, teamd. The kernel handles network packets efficiently and teamd handles logic and interface processing. Software, called runners, implement load balancing and active-backup logic, such as roundrobin. The following runners are available for teamd.

  • broadcast: a simple runner which transmits each pac ket from all ports.
  • round robin: a simple runner which transmits packets in a rou nd-robin fashing from each of the ports.
  • activebackup: this is a failover runner which watches for link changes and selects an active port for data transfers.
  • loadbalance: this runner monitors traffic and uses a hash function to try to reach a perfect balance when selecting ports for packet transmission.
  • lacp: impl ementsthe 802.3ad Link Aggregation Control Protocol. Can use the same transmit port selection possibilities as the loadbalance runner.

The following runners are available to teamd

Runner Explanation
broadcast A simple runner which transmit seach packet from all ports
roundrobin A simple runner which transmits packets in a round-robin fashing from each of the ports.
activebackup This is a failover runner which watches for link changes and selects an active port for data transfers
loadbalance This runner monitors traffic and uses a hash function to try to reach a perfect balance when selecting ports for packet transmission.
lacp Implements the 802.3ad LinkAggregation Control Protocol. Can use the same transmit port selection possibilities as the load balance runner.

 

All network interaction is done through a team interface, composed of multiple network port interfaces. When controlling teamed port interfaces using NetworkManager, and especially when fault finding, keep the following in mind:

  • Starting the network team interface does not automatically start the port interfaces.
  • Starting a port interface always starts the teamed interface.
  • Stopping the teamed interface also stops the port interfaces.
  • A teamed interface without port scan start static IP connections.
  • A team without ports waits for ports when starting DHCP connections.

 

Configure NIC teaming

The nmcli command can be used to create and manage team and port interfaces. The following four steps are used to create, activate and configure NIC teaming interface:

  1. Create the team interface.
  2. Determine the IPv4 and/or IPv6 attributes of the team interface.
  3. Assign the port interfaces.
  4. Bring the team and port interfaces up/down.

 

Create team interface

Use nmcli command to create a connection for the network team interface, with the following syntax:

Syntax:

nmcli con add type team con-name CNAME ifname INAME [config JSON]

where CNAME will be the name used to refer to the connection, INAME will be the interface name, and JSON specifies the runner to be used.
JSON has the following syntax:

'{"runner":{"name":"METHOD"}}'

where METHOD is one of the following: broadcast, round robin, activebackup, load balance, or lacp.

 

Create the team interface connection profile with nmcli

The following command will create a connection profile named myteam which will provide a team device named team0. The team mode will be activebackup and ethtool link monitoring will be used:

 

With static IP addressing:

# nmcli connection add type team con-name myteam ifname team0 config '{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}' ip4 192.151.27.17/32 gw4 192.151.27.62
Connection 'myteam' (6d3af1ac-dc3f-49a1-9c20-f7eed14636b1) successfully added.

My sample configuration file after executing the above command

# cat ifcfg-myteam
DEVICE=team0
TEAM_CONFIG="{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}"
BOOTPROTO=none
IPADDR=192.151.27.17
PREFIX=32
GATEWAY=192.151.27.62
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=myteam
UUID=6d3af1ac-dc3f-49a1-9c20-f7eed14636b1
ONBOOT=yes
DEVICETYPE=Team

 

With DHCP addressing:

# nmcli connection add type team con-name myteam ifname team0 config '{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}'

 

Assign the port interfaces

Use the nmcli command to create each of the port interfaces with the following syntax:

nmcli con add type team-slave con-name CNAME ifname INAME master TEAM

where CNAME will be the name used to refer to the port, INAME is the name of an existing interface, and TEAM specifies the connection name of the network team interface.

 

Create a profile for each team port (slave)

The master parameter must refer to the team device name, not the team profile name. In the example below the interfaces eno53 and eno54 are added to team0:

# nmcli connection add type team-slave con-name myteam-port1 ifname eno53 master team0
Connection 'myteam-port1' (02d469f7-5bf1-4ea6-82ea-9e0007d19afe) successfully added.

# nmcli connection add type team-slave con-name myteam-port2 ifname eno54 master team0
Connection 'myteam-port2' (386a0f1a-b017-462d-8f77-786d0d661217) successfully added.

My sample configuration file for the slaves

# cat ifcfg-myteam-port1
NAME=myteam-port1
UUID=02d469f7-5bf1-4ea6-82ea-9e0007d19afe
DEVICE=eno53
ONBOOT=yes
TEAM_MASTER=team0
DEVICETYPE=TeamPort
# cat ifcfg-myteam-port2
NAME=myteam-port2
UUID=386a0f1a-b017-462d-8f77-786d0d661217
DEVICE=eno54
ONBOOT=yes
TEAM_MASTER=team0
DEVICETYPE=TeamPort


Validate your changes

[root@openstack ~]# ifconfig team0
team0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.151.27.17  netmask 255.255.255.255  broadcast 192.151.27.17
        inet6 fe80::2084:8dda:d77f:9e61  prefixlen 64  scopeid 0x20
        ether d2:06:75:eb:a5:2e  txqueuelen 1000  (Ethernet)
        RX packets 3  bytes 214 (214.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 115  bytes 25305 (24.7 KiB)
        TX errors 0  dropped 4 overruns 0  carrier 0  collisions 0

 

Open another terminal and ping the local network gateway through the team0 interface. let this ping continue to run as you perform the following steps

# ping -I team0 192.151.27.62
PING 192.151.27.62 (192.151.27.62) from 192.151.27.17 team0: 56(84) bytes of data.
64 bytes from 192.151.27.62: icmp_seq=1 ttl=64 time=2.47 ms
64 bytes from 192.151.27.62: icmp_seq=2 ttl=64 time=3.05 ms
^C
--- 192.151.27.62 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 2.475/2.764/3.054/0.294 ms

 

Bring the team and port interfaces up/down

nmcli command can also be used to manage the connections for the team and port interfaces with the following syntax:

nmcli dev dis INAME
nmcli con up CNAME

INAME is the device name of the team or port interface to be managed. CNAME is the connection name of that interface where CNAME is the connection name of the team or port interface to be managed.

 

Confirm the team is working as expected with the teamdctl program. At a minimum, ensure the correct runner is in use or connectivity may not work:

# teamdctl team0 state
setup:
  runner: activebackup
ports:
  eno53
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
  eno54
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
runner:
  active port: eno53

Open a new terminal and let us bring down the active interface eno53 in the team0 and check the impact

# nmcli dev dis eno53
Device 'eno53' successfully disconnected.
# ping -I team0 192.151.27.62
PING 192.151.27.62 (192.151.27.62) from 192.151.27.17 team0: 56(84) bytes of data.
64 bytes from 192.151.27.62: icmp_seq=1 ttl=64 time=7.44 ms
64 bytes from 192.151.27.62: icmp_seq=2 ttl=64 time=9.84 ms
64 bytes from 192.151.27.62: icmp_seq=3 ttl=64 time=4.36 ms
64 bytes from 192.151.27.62: icmp_seq=63 ttl=64 time=77.4 ms
^C
--- 192.151.27.62 ping statistics ---
63 packets transmitted, 63 received, 0% packet loss, time 62092ms
rtt min/avg/max/mdev = 0.586/14.202/125.945/18.422 ms

But there is no impact to my active connection and the active port changes to eno54

# teamdctl team0 state
setup:
  runner: activebackup
ports:
  eno54
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
runner:
  active port: eno54

Bring the original port interface back up and bring the other port interface down. But before that let us get the connection name for the port1

# nmcli con show
NAME                   UUID                                  TYPE            DEVICE
myteam                 6d3af1ac-dc3f-49a1-9c20-f7eed14636b1  team            team0
myteam-port2           386a0f1a-b017-462d-8f77-786d0d661217  802-3-ethernet  eno54
myteam-port1           02d469f7-5bf1-4ea6-82ea-9e0007d19afe  802-3-ethernet  --

So from the above output we know myteam-port1 is inactive so let it bring back UP.

# nmcli con up myteam-port1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/94)

# nmcli dev dis eno54
Device 'eno54' successfully disconnected.

And now as wee see the active port is back to eno53

# teamdctl team0 state
setup:
  runner: activebackup
ports:
  eno53
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
runner:
  active port: eno53

Again note that the ping continues to reach the local gateway.

 

I hope the steps from the article to configure NIC teaming on Linux was helpful. Let me know your suggestions and feedback using the comment section.

 

Deepak Prasad

Deepak Prasad

Deepak Prasad is the founder of GoLinuxCloud, bringing over a decade of expertise in Linux, Python, Go, Laravel, DevOps, Kubernetes, Git, Shell scripting, OpenShift, Networking, and Security. His extensive experience spans development, DevOps, networking, and security, ensuring robust and efficient solutions for diverse projects.

Certifications and Credentials:

  • Certified Kubernetes Application Developer (CKAD)
  • Go Developer Certification
  • Linux Foundation Certified System Administrator (LFCS)
  • Certified Ethical Hacker (CEH)
  • Python Institute PCAP (Certified Associate in Python Programming)
You can connect with him on his LinkedIn profile and join his Facebook and LinkedIn page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

2 thoughts on “How to create or configure NIC Teaming using nmcli (CentOS / RHEL 7/8)”

  1. Is there a way to lock the team interface to a specific MAC? It keeps changing between those available from the hardware components that make it up.

    Reply
    • have you disabled consistent network device naming?
      That should not happen ideally but any how you can achieve that by binding the interface to MAC by using MACADDR variable in your network configuration file inside /etc/sysconfig/network-scripts/ifcfg-

      Reply

Leave a Comment