I’ve heard a lot about link aggregation, teaming or bonding but I’ve never tried it. Until now. In this post I will demonstrate how to setup NIC teaming on CentOS 7 virtual host.
Setup NIC teaming on Server
I can see 2 network cards (both with IP address assigned by DHCP):
nmcli device
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected System eth0
eth1 ethernet connected Wired connection 1
lo loopback unmanaged --
[root@centos-team ~]# nmcli connection
NAME UUID TYPE DEVICE
Wired connection 1 b709aa19-505f-4b7a-8513-a0bf8bfb3ff8 802-3-ethernet eth1
System eth0 4628dca0-dc29-4c47-9f4a-743a08010ea5 802-3-ethernet eth0
[root@centos-team ~]# ip address list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:c6:b8:9f brd ff:ff:ff:ff:ff:ff
inet 192.168.122.41/24 brd 192.168.122.255 scope global dynamic eth0
valid_lft 3536sec preferred_lft 3536sec
inet6 fe80::5054:ff:fec6:b89f/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:ee:47:16 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.187/24 brd 192.168.122.255 scope global dynamic eth1
valid_lft 3538sec preferred_lft 3538sec
inet6 fe80::5054:ff:feee:4716/64 scope link
valid_lft forever preferred_lft forever
Now I want to team these to NICs together. I will assign static IP adress to teamed device (team0).
I’ve created two configuration for each NIC – ifcfg-eth0 and ifcfg-eth1:
[root@centos-team network-scripts]# cat ifcfg-eth0 DEVICE="eth0" DEVICETYPE="TeamPort" ONBOOT="yes" BOOTPROTO="none" TEAM_MASTER="team0" [root@centos-team network-scripts]# cat ifcfg-eth1 DEVICE="eth1" DEVICETYPE="TeamPort" ONBOOT="yes" BOOTPROTO="none" TEAM_MASTER="team0"
DEVICETYPE line defines that this devices is part of team. TEAM_MASTER defines to which master device it belongs. Next step is to define team device:
[root@centos-team network-scripts]# cat ifcfg-team0
DEVICE="team0"
DEVICETYPE="Team"
ONBOOT="yes"
BOOTPROTO="none"
NETMASK=255.255.255.0
IPADDR=192.168.122.200
TEAM_CONFIG='{"runner": {"name": "roundrobin"}}'
Device will be configured with IP address of 192.168.122.200. Parameter TEAM_CONFIG stores teamd configuration. For more information seeman teamd.conf. This config says that load on team device (team0) will be split on slave devices (eth0 and eth1) in round-robin fashion. It will basically join these slave interfaces together to achieve double network bandwidth. After reboot it looks like this:
[root@centos-team ~]# ip address list
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team0 state UP qlen 1000
link/ether 52:54:00:c6:b8:9f brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master team0 state UP qlen 1000
link/ether 52:54:00:c6:b8:9f brd ff:ff:ff:ff:ff:ff
4: team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 52:54:00:c6:b8:9f brd ff:ff:ff:ff:ff:ff
inet 192.168.122.200/24 brd 192.168.122.255 scope global team0
valid_lft forever preferred_lft forever
inet6 fe80::5054:ff:fec6:b89f/64 scope link tentative dadfailed
valid_lft forever preferred_lft forever
[root@centos-team ~]# nmcli connection
NAME UUID TYPE DEVICE
Team team0 702de3eb-2e80-897c-fd52-cd0494dd8123 team team0
System eth1 9c92fad9-6ecb-3e6c-eb4d-8a47c6f50c04 802-3-ethernet eth1
System eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 802-3-ethernet eth0
[root@centos-team ~]# nmcli device
DEVICE TYPE STATE CONNECTION
eth0 ethernet connected System eth0
eth1 ethernet connected System eth1
team0 team connected Team team0
lo loopback unmanaged --
To see wich values you can insert on the “TEAM_CONFIG=” flag their is i quick example of the configurations files you can see here and choose wich configuration fits best:
ls /usr/share/doc/teamd-*/example_configs/ activebackup_arp_ping_1.conf activebackup_multi_lw_1.conf loadbalance_2.conf activebackup_arp_ping_2.conf activebackup_nsna_ping_1.conf loadbalance_3.conf activebackup_ethtool_1.conf broadcast.conf random.conf activebackup_ethtool_2.conf lacp_1.conf roundrobin_2.conf activebackup_ethtool_3.conf loadbalance_1.conf roundrobin.conf
To view one of the included files, such as activebackup_ethtool_1.conf, enter the following command:
cat /usr/share/doc/teamd-*/example_configs/activebackup_ethtool_1.conf
{
"device": "team0",
"runner": {"name": "activebackup"},
"link_watch": {"name": "ethtool"},
"ports": {
"eth1": {
"prio": -10,
"sticky": true
},
"eth2": {
"prio": 100
}
}
}