Table of Contents
Introduction
Network Teaming, Bonding or Link Aggregation, We are about to explore how to create a Linux Team interface. To create a network team interface we need a minimum of two numbers of physical or virtual interfaces.
By combing number of interfaces, a team will be created, It’s created to provide more link redundancy to increase the speed of connection, to keep the uptime of server up and running while anyone of interface failure or cable disconnectivity. This makes the critical business production servers running smooth by avoiding any downtimes.
Let’s see the type of available network teaming in Linux.
Types of Network Teaming
Modes | Mode No | A Short Description |
---|---|---|
RoundRobin | 0 | Send traffic over the available slave ports in a round-robin fashion. |
Active-Backup | 1 | Monitors the link for changes and selects the active port to send the traffics. |
Balance-XOR | 2 | Transmit based on the selected transmit hash policy. Transmit based on the selected transmit hash policy. |
Broadcast | 3 | Sends packets on all slave ports. |
LACP | 4 | Provides load balancing by implementing the Link Aggregation Control Protocol 802.3ad on the slave ports. |
LoadBalance | 5 | While passive mode, it uses the Berkeley Packet Filter (BPF) hash function to select the port that is used to send packets. While active mode, it uses a balancing algorithm to distribute outgoing packets over the available slaves. |
Random | 6 | Randomly selects a slave to send each outgoing packet. |
If you are planning to set up network teaming manually by creating interface files, the sample interface files will be underlying under /usr/share/doc/teamd/.
[root@prodsrv1 ~]# ls -lthr /usr/share/doc/teamd/example_ifcfgs/*/*
-rw-r--r--. 1 root root 293 Mar 17 2017 /usr/share/doc/teamd/example_ifcfgs/3/ifcfg-team_test0
-rw-r--r--. 1 root root 107 Mar 17 2017 /usr/share/doc/teamd/example_ifcfgs/3/ifcfg-eth2
-rw-r--r--. 1 root root 123 Mar 17 2017 /usr/share/doc/teamd/example_ifcfgs/3/ifcfg-eth1
-rw-r--r--. 1 root root 257 Mar 17 2017 /usr/share/doc/teamd/example_ifcfgs/2/ifcfg-team_test0
-rw-r--r--. 1 root root 74 Mar 17 2017 /usr/share/doc/teamd/example_ifcfgs/2/ifcfg-eth2
-rw-r--r--. 1 root root 74 Mar 17 2017 /usr/share/doc/teamd/example_ifcfgs/2/ifcfg-eth1
-rw-r--r--. 1 root root 157 Mar 17 2017 /usr/share/doc/teamd/example_ifcfgs/1/ifcfg-team_test0
-rw-r--r--. 1 root root 73 Mar 17 2017 /usr/share/doc/teamd/example_ifcfgs/1/ifcfg-eth2
-rw-r--r--. 1 root root 73 Mar 17 2017 /usr/share/doc/teamd/example_ifcfgs/1/ifcfg-eth1
[root@prodsrv1 ~]#
Else, if you plan to create with config options the samples will be under below location.
[root@prodsrv1 ~]# ls -lthr /usr/share/doc/teamd/example_configs/
total 64K
-rw-r--r--. 1 root root 244 Mar 17 2017 roundrobin_2.conf
-rw-r--r--. 1 root root 97 Mar 17 2017 roundrobin.conf
-rw-r--r--. 1 root root 93 Mar 17 2017 random.conf
-rw-r--r--. 1 root root 183 Mar 17 2017 loadbalance_3.conf
-rw-r--r--. 1 root root 140 Mar 17 2017 loadbalance_2.conf
-rw-r--r--. 1 root root 98 Mar 17 2017 loadbalance_1.conf
-rw-r--r--. 1 root root 209 Mar 17 2017 lacp_1.conf
-rw-r--r--. 1 root root 96 Mar 17 2017 broadcast.conf
-rw-r--r--. 1 root root 318 Mar 17 2017 activebackup_tipc.conf
-rw-r--r--. 1 root root 285 Mar 17 2017 activebackup_nsna_ping_1.conf
-rw-r--r--. 1 root root 447 Mar 17 2017 activebackup_multi_lw_1.conf
-rw-r--r--. 1 root root 241 Mar 17 2017 activebackup_ethtool_3.conf
-rw-r--r--. 1 root root 212 Mar 17 2017 activebackup_ethtool_2.conf
-rw-r--r--. 1 root root 194 Mar 17 2017 activebackup_ethtool_1.conf
-rw-r--r--. 1 root root 465 Mar 17 2017 activebackup_arp_ping_2.conf
-rw-r--r--. 1 root root 305 Mar 17 2017 activebackup_arp_ping_1.conf
[root@prodsrv1 ~]#
Creating a Team Interface Using nmcli
Listing Physical Interfaces
Let’s start to list the available physical interfaces in our virtual or physical server to create a network teaming interface.
[root@prodsrv1 ~]# nmcli device
DEVICE TYPE STATE CONNECTION
ens160 ethernet connected ens160
ens224 ethernet disconnected --
ens256 ethernet disconnected --
lo loopback unmanaged --
[root@prodsrv1 ~]#
# nmcli device ## Full form
or
# nmcli dev ## Short form
Listing the connection profile
To list the connection profiles we can use the full form or short form as well.
# nmcli connection ## Full form
or
# nmcli con ## short form
The output of connections shows it not yet in the upstate.
[root@prodsrv1 ~]# nmcli connection
NAME UUID TYPE DEVICE
ens160 d849fd31-6cdc-4363-9ffe-c8ea9d4af0dc ethernet ens160
ens224 5824aa6d-68ee-4145-80b9-21403812d856 ethernet --
ens256 cc479e9f-64bf-4e0e-b7a2-80e4eabeff4b ethernet --
[root@prodsrv1 ~]#
Let’s delete the profile of ens224 and ens256 before creating our teaming.
Creating a Team network
First of all, create a team interface in your choice of name. In this guide, I’m about to use team0.
# nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name": "activebackup"}}'
# nmcli connection
Once after creating team0 interface assign the IP address, gateway, DNS server information etc.
# nmcli connection modify team0 ipv4.addresses 192.168.107.105/24 ipv4.method manual
# nmcli connection modify team0 ipv4.gateway 192.168.107.2 ipv4.dns 192.168.107.2 ipv4.dns-search linuxsysadmins.local
# nmcli connection modify team0 autoconnect yes ipv4.method manual ipv6.method ignore
By running the individual command to assign IP, DNS we can run all in one command as well. To configure the interface in a single command we need to know about what are the parameters in an interface and what is the use of each line. To know more about an interface file entry read Configure a Network interface on CentOS8.
# nmcli connection modify team0 ipv4.addresses 192.168.107.105/24 ipv4.method manual ipv4.gateway 192.168.107.2 ipv4.dns 192.168.107.2 ipv4.dns-search linuxsysadmins.local ipv4.method manual ipv6.method ignore connection.autoconnect yes
Once configured team interface, bring it online.
# nmcli connection up team0
Verify the status. Now we should get the team interface runner mode without any slaves.
[root@prodsrv1 ~]# teamdctl team0 state
setup:
runner: activebackup
runner:
active port:
[root@prodsrv1 ~]#
Let’s start to create slave interfaces and add it to master team interface team0.
Creating and adding Slave Interfaces
To add a slave interface into existing team interface we can use below commands.
# nmcli connection add type ethernet con-name team0-slave1 ifname ens224 master team0
# nmcli connection add type ethernet con-name team0-slave2 ifname ens256 master team0
Output for your reference
[root@prodsrv1 ~]# nmcli connection add type ethernet con-name team0-slave1 ifname ens224 master team0
Connection 'team0-slave1' (58c5f0af-2f95-43e5-b0b4-07965376c748) successfully added.
[root@prodsrv1 ~]# nmcli connection add type ethernet con-name team0-slave2 ifname ens256 master team0
Connection 'team0-slave2' (095f7444-fbf7-4727-91e5-acc652b74881) successfully added.
[root@prodsrv1 ~]#
Once created with master team interface team0 and slave interfaces print using “nmcli connection
“.
[root@prodsrv1 ~]# nmcli connection
NAME UUID TYPE DEVICE
ens160 d849fd31-6cdc-4363-9ffe-c8ea9d4af0dc ethernet ens160
team0 3394c156-e6fd-41ae-be40-3b52ca1b4bdf team team0
team0-slave1 58c5f0af-2f95-43e5-b0b4-07965376c748 ethernet ens224
team0-slave2 095f7444-fbf7-4727-91e5-acc652b74881 ethernet ens256
[root@prodsrv1 ~]#
Bring up the Slave interfaces.
By following bring up all the slave interfaces once after configuring IP for master team interface (team0).
[root@prodsrv1 ~]# nmcli connection up team0-slave1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)
[root@prodsrv1 ~]#
[root@prodsrv1 ~]# nmcli connection up team0-slave2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
[root@prodsrv1 ~]#
Verify the Status
Once after creating the teaming interface check for the status using
# teamdctl team0 state
The output clearly shows Link of both interfaces ens224 and ens256 are in the upstate.
[root@prodsrv1 ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
ens224
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
ens256
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens224
[root@prodsrv1 ~]#
Verify the Availability of Interfaces
Disconnect any one of the physical interface ens224 or ens256 from the team0 interface and check the availability.
# nmcli device disconnect ens224
# teamdctl team0 state
Once again verify the status of team0 interface.
[root@prodsrv1 ~]# nmcli device disconnect ens224
Device 'ens224' successfully disconnected.
[root@prodsrv1 ~]#
[root@prodsrv1 ~]# teamdctl team0 state
setup:
runner: activebackup
ports:
ens256
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: ens256
[root@prodsrv1 ~]#
Below is the proof of Interface status and ping status from source to the destination. While running a continuous ping and bringing down any one of the interfaces will not break the teaming.
That’s it we have successfully created a Team interface on a systemd based Linux server.
Conclusion
To create a network teaming we need to follow only 4 steps, By following the above guide we are good with creating our first network teaming interface in any flavour of Linux servers. Subscribe to newsletter for more networking-related articles.