How to Configure Network Teaming in CentOS/RHEL 7

In this post, we will outline the steps to combine two network links using network teaming to provide link redundancy or higher throughput.

What is Network Teaming

Network teaming is a method for linking NICs together logically to allow for failover or higher throughput. Teaming is a new implementation that does not affect the older bonding driver in the Linux kernel; it offers an alternate implementation. CentOS/RHEL 7 supports channel bonding for backward compatibility. Network teaming provides better performance and is more extensible because of its modular design.

CentOS/RHEL 7 implements network teaming with a small kernel driver and a userspace 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 to teamd:

  • broadcast: a simple runner which transmits each packet from all ports.
  • roundrobin: a simple runner which transmits packets in a round-robin fashion 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 Link Aggregation Control Protocol. Can use the same transmit port selection possibilities as the loadbalance 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 ports can start static IP connections.
  • A team without ports waits for ports when starting DHCP connections.
  • A team with a DHCP connection waiting for ports completes when a port with a carrier is added.
  • A team with a DHCP connection waiting for ports continues waiting when a port without a carrier is added.

Configuring Network Teams

The nmcli command can be used to create and manage team and port interfaces. The following four steps are used to create and activate a network team 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 the team interface

Use the nmcli command to create a connection for the network team interface, with the following 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, roundrobin, activebackup, loadbalance, or lacp. For example:

# nmcli con add type team con-name team0 ifname team0 config '{"runner": {"name": "loadbalance"}}'

Determine the IPv4/IPv6 attributes of the team interface

Once the network team interface is created, IPv4 and/or IPv6 attributes can be assigned to it. If DHCP is available, this step is optional, because the default attributes configure the interface to get its IP settings using DHCP. The following example demonstrates how to assign a static IPv4 address to the team0 interface:

# nmcli con mod team0 ipv4.addresses 1.2.3.4/24
# nmcli con mod team0 ipv4.method manual

Note that the ipv4.addresses have to be assigned before the ipv4.method can be set to manual

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.

The connection name can be explicitly specified, or it will be team-slave-IFACE by default. For example:

# nmcli con add type team-slave ifname eth1 master team0
# nmcli con add type team-slave ifname eth2 con-name team0-eth2 master team0

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. For example:

# nmcli con up team0
# nmcli dev dis eth2

When the team interface is up, the teamdctl command can be used to display the team’s state. The output of this command includes the status of the port interfaces.

# teamdctl team0 state
setup:
    runner: roundrobin
ports:
     eth1
       link watches:
          link summary: up
          instance[link_watch_0]:
          name: ethtool
          link: up
eth2
   link watches:
    link summary: up
      instance[link_watch_0]:
      name: ethtool
      link: up