8.10. Configure a Network Team Using the Command Line
8.10.1. Configure Network Teaming Using nmcli
To view the connections available on the system:
Copy to Clipboard
Copied!
nmcli connection show
~]$ nmcli connection show
NAME UUID TYPE DEVICE
enp2s0 0e8185a1-f0fd-4802-99fb-bedbb31c689b 802-3-ethernet --
enp1s0 dfe1f57b-419d-4d1c-aaf5-245deab82487 802-3-ethernet --
To view the devices available on the system:
Copy to Clipboard
Copied!
nmcli device status
~]$ nmcli device status
DEVICE TYPE STATE CONNECTION
virbr0 bridge connected virbr0
ens3 ethernet connected ens3
To create a new team interface, with name ServerA:
Copy to Clipboard
Copied!
NetworkManager will set its internal parameter
nmcli connection add type team ifname ServerA
~]$ nmcli connection add type team ifname ServerA
Connection 'team-ServerA' (b954c62f-5fdd-4339-97b0-40efac734c50) successfully added.
connection.autoconnect
to yes
and as no IP
address was given ipv4.method
will be set to auto
. NetworkManager will also write a configuration file to /etc/sysconfig/network-scripts/ifcfg-team-ServerA
where the corresponding ONBOOT will be set to yes
and BOOTPROTO will be set to dhcp
.
Note that manual changes to the ifcfg file will not be noticed by NetworkManager until the interface is next brought up. See Section 2.7, “Using NetworkManager with sysconfig files” for more information on using configuration files.
To view the other values assigned:
Copy to Clipboard
Copied!
As no JSON configuration file was specified the default values apply. See the
Copy to Clipboard
Copied!
nmcli con show team-ServerA
~]$ nmcli con show team-ServerA
connection.id: team-ServerA
connection.uuid: b954c62f-5fdd-4339-97b0-40efac734c50
connection.interface-name: ServerA
connection.type: team
connection.autoconnect: yes
…
ipv4.method: auto
[output truncated]
teamd.conf(5)
man page for more information on the team JSON parameters and their default values. Notice that the name was derived from the interface name by prepending the type. Alternatively, specify a name with the con-name
option as follows:
nmcli connection add type team con-name Team0 ifname ServerB
~]$ nmcli connection add type team con-name Team0 ifname ServerB
Connection 'Team0' (5f7160a1-09f6-4204-8ff0-6d96a91218a7) successfully added.
To view the team interfaces just configured, enter a command as follows:
Copy to Clipboard
Copied!
nmcli con show
~]$ nmcli con show
NAME UUID TYPE DEVICE
team-ServerA b954c62f-5fdd-4339-97b0-40efac734c50 team ServerA
enp2s0 0e8185a1-f0fd-4802-99fb-bedbb31c689b 802-3-ethernet --
enp1s0 dfe1f57b-419d-4d1c-aaf5-245deab82487 802-3-ethernet --
Team0 5f7160a1-09f6-4204-8ff0-6d96a91218a7 team ServerB
To change the name assigned to a team, enter a command in the following format:
Copy to Clipboard
Copied!
nmcli con mod old-team-name connection.id new-team-name
nmcli con mod old-team-name connection.id new-team-name
To load a team configuration file for a team that already exists:
Copy to Clipboard
Copied!
You can specify the team configuration either as a JSON string or provide a file name containing the configuration. The file name can include the path. In both cases, what is stored in the
nmcli connection modify team-name team.config JSON-config
nmcli connection modify team-name team.config JSON-config
team.config
property is the JSON string. In the case of a JSON string, use single quotes around the string and paste the entire string to the command line.
To review the
Copy to Clipboard
Copied!
team.config
property: nmcli con show team-name | grep team.config
nmcli con show team-name | grep team.config
When the
team.config
property is set, all the other team properties are updated accordingly.
It is also possible a more flexible way of exposing and setting particular team options without modifying directly the corresponding JSON string. You can do this by using the other available team properties to set the related team options one by one to the required values. As a result, the
team.config
property is updated to match the new values.
For example, to set the
Copy to Clipboard
Copied!
The required
team.link-watchers
property which allows to specify one or multiple link-watchers
, enter a command in the following format: nmcli connection modify team-name team.link-watchers "name=ethtool delay-up=5, name=nsna_ping target-host=target.host"
nmcli connection modify team-name team.link-watchers "name=ethtool delay-up=5, name=nsna_ping target-host=target.host"
link-watchers
are separated by comma and the attributes which belong to the same link-watcher
are separated by space.
To set the
Copy to Clipboard
Copied!
team.runner
and the team.link-watchers
properties, enter a command in the following format: nmcli connection modify team-name team.runner activebackup team.link-watchers "name=ethtool delay-up=5, name=nsna_ping target-host=target.host"
nmcli connection modify team-name team.runner activebackup team.link-watchers "name=ethtool delay-up=5, name=nsna_ping target-host=target.host"
This is equivalent to set the
Copy to Clipboard
Copied!
team.config
property to the corresponding JSON string: nmcli connection modify team-name team.config '{"runner": {"name": "activebackup"}, "link_watch": [{"name": "ethtool", "delay_up": 5},{"name": "nsna_ping", "target_host ": "target.host"}]'
nmcli connection modify team-name team.config '{"runner": {"name": "activebackup"}, "link_watch": [{"name": "ethtool", "delay_up": 5},{"name": "nsna_ping", "target_host ": "target.host"}]'
To add an interface enp1s0 to
Copy to Clipboard
Copied!
Team0
, with the name Team0-port1, issue a command as follows:
nmcli con add type ethernet con-name Team0-port1 ifname enp1s0 slave-type team master Team0
~]$ nmcli con add type ethernet con-name Team0-port1 ifname enp1s0 slave-type team master Team0
Connection 'Team0-port1' (ccd87704-c866-459e-8fe7-01b06cf1cffc) successfully added.
Similarly, to add another interface, enp2s0, with the name Team0-port2, issue a command as follows:
Copy to Clipboard
Copied!
nmcli only supports Ethernet ports.
nmcli con add type ethernet con-name Team0-port2 ifname enp2s0 slave-type team master Team0
~]$ nmcli con add type ethernet con-name Team0-port2 ifname enp2s0 slave-type team master Team0
Connection 'Team0-port2' (a89ccff8-8202-411e-8ca6-2953b7db52dd) successfully added.
To open a team, the ports must be brought up first as follows:
Copy to Clipboard
Copied!
Copy to Clipboard
Copied!
nmcli connection up Team0-port1
~]$ nmcli connection up Team0-port1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/2)
nmcli connection up Team0-port2
~]$ nmcli connection up Team0-port2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/3)
You can verify that the team interface was brought up by the activation of the ports, as follows:
Copy to Clipboard
Copied!
Alternatively, issue a command to open the team as follows:
Copy to Clipboard
Copied!
ip link
~]$ ip link
3: Team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT
link/ether 52:54:00:76:6f:f0 brd ff:ff:ff:ff:ff:f
nmcli connection up Team0
~]$ nmcli connection up Team0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
See Section 3.3, “Configuring IP Networking with nmcli” for an introduction to nmcli
8.10.2. Creating a Network Team Using teamd
Note
Configurations created using teamd are not persistent, and as such it may be necessary to create a team using the steps defined in Section 8.10.1, “Configure Network Teaming Using nmcli” or Section 8.10.3, “Creating a Network Team Using ifcfg Files”.
To create a network team, a JSON format configuration file is required for the virtual interface that will serve as the interface to the team of ports or links. A quick way is to copy the example configuration files and then edit them using an editor running with
Copy to Clipboard
Copied!
To view one of the included files, such as
Copy to Clipboard
Copied!
Create a working configurations directory to store
Copy to Clipboard
Copied!
Copy the file you have chosen to your working directory and edit it as necessary. As an example, you could use a command with the following format:
Copy to Clipboard
Copied!
To edit the file to suit your environment, for example to change the interfaces to be used as ports for the network team, open the file for editing as follows:
Copy to Clipboard
Copied!
Make any necessary changes and save the file. See the
root
privileges. To list the available example configurations, enter the following command:
ls /usr/share/doc/teamd-*/example_configs/
~]$ 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
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": { "enp1s0": { "prio": -10, "sticky": true }, "enp2s0": { "prio": 100 } } }
~]$ cat /usr/share/doc/teamd-*/example_configs/activebackup_ethtool_1.conf
{
"device": "team0",
"runner": {"name": "activebackup"},
"link_watch": {"name": "ethtool"},
"ports": {
"enp1s0": {
"prio": -10,
"sticky": true
},
"enp2s0": {
"prio": 100
}
}
}
teamd
configuration files. For example, as normal user, enter a command with the following format:
mkdir ~/teamd_working_configs
~]$ mkdir ~/teamd_working_configs
cp /usr/share/doc/teamd-*/example_configs/activebackup_ethtool_1.conf \ ~/teamd_working_configs/activebackup_ethtool_1.conf
~]$ cp /usr/share/doc/teamd-*/example_configs/activebackup_ethtool_1.conf \ ~/teamd_working_configs/activebackup_ethtool_1.conf
vi ~/teamd_working_configs/activebackup_ethtool_1.conf
~]$ vi ~/teamd_working_configs/activebackup_ethtool_1.conf
vi(1)
man page for help on using the vi editor or use your preferred editor.
Note that it is essential that the interfaces to be used as ports within the team must not be active, that is to say, they must be “down”, when adding them into a team device. To check their status, issue the following command:
Copy to Clipboard
Copied!
In this example we see that both the interfaces we plan to use are “UP”.
ip link show
~]$ ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: em1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 52:54:00:d5:f7:d4 brd ff:ff:ff:ff:ff:ff
3: em2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 52:54:00:d8:04:70 brd ff:ff:ff:ff:ff:ff
To take down an interface, issue a command as
Copy to Clipboard
Copied!
Repeat for each interface as necessary.
root
in the following format:
ip link set down em1
~]# ip link set down em1
To create a team interface based on the configuration file, as
Copy to Clipboard
Copied!
Then issue a command in the following format:
Copy to Clipboard
Copied!
The
root
user, change to the working configurations directory (teamd_working_configs in this example):
cd /home/userteamd_working_configs
~]# cd /home/userteamd_working_configs
teamd -g -f activebackup_ethtool_1.conf -d
~]# teamd -g -f activebackup_ethtool_1.conf -d
Using team device "team0".
Using PID file "/var/run/teamd/team0.pid"
Using config file "/home/user/teamd_working_configs/activebackup_ethtool_1.conf"
-g
option is for debug messages, -f
option is to specify the configuration file to load, and the -d
option is to make the process run as a daemon after startup. See the teamd(8)
man page for other options.
To check the status of the team, issue the following command as
Copy to Clipboard
Copied!
root
:
teamdctl team0 state
~]# teamdctl team0 state
setup:
runner: activebackup
ports:
em1
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
em2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
runner:
active port: em1
To apply an address to the network team interface, team0, issue a command as
Copy to Clipboard
Copied!
root
in the following format:
ip addr add 192.168.23.2/24 dev team0
~]# ip addr add 192.168.23.2/24 dev team0
To check the IP address of a team interface, issue a command as follows:
Copy to Clipboard
Copied!
ip addr show team0
~]$ ip addr show team0
4: team0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP
link/ether 16:38:57:60:20:6f brd ff:ff:ff:ff:ff:ff
inet 192.168.23.2/24 scope global team0
valid_lft forever preferred_lft forever
inet6 2620:52:0:221d:1438:57ff:fe60:206f/64 scope global dynamic
valid_lft 2591880sec preferred_lft 604680sec
inet6 fe80::1438:57ff:fe60:206f/64 scope link
valid_lft forever preferred_lft forever
To activate the team interface, or to bring it “up”, issue a command as
Copy to Clipboard
Copied!
root
in the following format:
ip link set dev team0 up
~]# ip link set dev team0 up
To temporarily deactivate the team interface, or to take it “down”, issue a command as
Copy to Clipboard
Copied!
root
in the following format:
ip link set dev team0 down
~]# ip link set dev team0 down
To terminate, or kill, an instance of the team daemon, as
Copy to Clipboard
Copied!
The
root
user, issue a command in the following format:
teamd -t team0 -k
~]# teamd -t team0 -k
-k
option is to specify that the instance of the daemon associated with the device team0 is to be killed. See the teamd(8)
man page for other options.
For help on command-line options for
Copy to Clipboard
Copied!
In addition, see the
teamd
, issue the following command:
teamd -h
~]$ teamd -h
teamd(8)
man page.
8.10.3. Creating a Network Team Using ifcfg Files
To create a networking team using
Copy to Clipboard
Copied!
This creates the interface to the team, in other words, this is the
ifcfg
files, create a file in the /etc/sysconfig/network-scripts/
directory as follows:
DEVICE=team0 DEVICETYPE=Team ONBOOT=yes BOOTPROTO=none IPADDR=192.168.11.1 PREFIX=24 TEAM_CONFIG='{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}'
DEVICE=team0
DEVICETYPE=Team
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.11.1
PREFIX=24
TEAM_CONFIG='{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}'
master
.
To create a port to be a member of team0, create one or more files in the
Copy to Clipboard
Copied!
Add additional port interfaces similar to the above as required, changing the DEVICE and HWADDR field to match the ports (the network devices) being added. If port priority is not specified by
/etc/sysconfig/network-scripts/
directory as follows:
DEVICE=enp1s0 HWADDR=D4:85:64:01:46:9E DEVICETYPE=TeamPort ONBOOT=yes TEAM_MASTER=team0 TEAM_PORT_CONFIG='{"prio": 100}'
DEVICE=enp1s0
HWADDR=D4:85:64:01:46:9E
DEVICETYPE=TeamPort
ONBOOT=yes
TEAM_MASTER=team0
TEAM_PORT_CONFIG='{"prio": 100}'
prio
it defaults to 0
; it accepts negative and positive values in the range -32,767
to +32,767
.
Specifying the hardware or MAC address using the
HWADDR
directive will influence the device naming procedure. This is explained in Chapter 11, Consistent Network Device Naming.
To open the network team, issue the following command as
Copy to Clipboard
Copied!
To view the network team, issue the following command:
Copy to Clipboard
Copied!
root
:
ifup team0
~]# ifup team0
ip link show
~]$ ip link show
8.10.4. Add a Port to a Network Team Using iputils
To add a port em1 to a network team team0, using the ip utility, issue the following commands as
Copy to Clipboard
Copied!
Add additional ports as required. Team driver will bring ports up automatically.
root
:
ip link set dev em1 down ip link set dev em1 master team0
~]# ip link set dev em1 down
~]# ip link set dev em1 master team0
8.10.5. Listing the ports of a Team Using teamnl
To view or list the ports in a network team, using the teamnl utility, issue the following command as
Copy to Clipboard
Copied!
root
:
teamnl team0 ports
~]# teamnl team0 ports
em2: up 100 fullduplex
em1: up 100 fullduplex
8.10.6. Configuring Options of a Team Using teamnl
To view or list all currently available options, using the teamnl utility, issue the following command as
Copy to Clipboard
Copied!
To configure a team to use active backup mode, issue the following command as
Copy to Clipboard
Copied!
root
:
teamnl team0 options
~]# teamnl team0 options
root
:
teamnl team0 setoption mode activebackup
~]# teamnl team0 setoption mode activebackup
8.10.7. Add an Address to a Network Team Using iputils
To add an address to a team team0, using the ip utility, issue the following command as
Copy to Clipboard
Copied!
root
:
ip addr add 192.168.252.2/24 dev team0
~]# ip addr add 192.168.252.2/24 dev team0
8.10.8. open an Interface to a Network Team Using iputils
To activate or “open” an interface to a network team, team0, using the ip utility, issue the following command as
Copy to Clipboard
Copied!
root
:
ip link set team0 up
~]# ip link set team0 up
8.10.9. Viewing the Active Port Options of a Team Using teamnl
To view or list the
Copy to Clipboard
Copied!
activeport
option in a network team, using the teamnl utility, issue the following command as root
:
teamnl team0 getoption activeport
~]# teamnl team0 getoption activeport
0
8.10.10. Setting the Active Port Options of a Team Using teamnl
To set the
Copy to Clipboard
Copied!
To check the change in team port options, issue the following command as
Copy to Clipboard
Copied!
activeport
option in a network team, using the teamnl utility, issue the following command as root
:
teamnl team0 setoption activeport 5
~]# teamnl team0 setoption activeport 5
root
:
teamnl team0 getoption activeport
~]# teamnl team0 getoption activeport
5