Questo contenuto non è disponibile nella lingua selezionata.
8.10. Configure a Network Team Using the Command Line
8.10.1. Configure Network Teaming Using nmcli Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To view the connections available on the system:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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!
Toggle word wrap
Toggle overflow
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!
Toggle word wrap
Toggle overflow
NetworkManager will set its internal parameter
nmcli connection add type team ifname ServerA
~]$ nmcli connection add type team ifname ServerAnmcli 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!
Toggle word wrap
Toggle overflow
As no JSON configuration file was specified the default values apply. See the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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 ServerBnmcli connection add type team con-name Team0 ifname ServerBnmcli connection add type team con-name Team0 ifname ServerBnmcli 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!
Toggle word wrap
Toggle overflow
To change the name assigned to a team, enter a command in the following format:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
nmcli con mod old-team-name connection.id new-team-name
nmcli con mod old-team-name connection.id new-team-namenmcli con mod old-team-name connection.id new-team-namenmcli con mod old-team-name connection.id new-team-namenmcli 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!
Toggle word wrap
Toggle overflow
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-confignmcli connection modify team-name team.config JSON-confignmcli connection modify team-name team.config JSON-confignmcli 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!
Toggle word wrap
Toggle overflow
team.config
property: nmcli con show team-name | grep team.config
nmcli con show team-name | grep team.confignmcli con show team-name | grep team.confignmcli 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!
Toggle word wrap
Toggle overflow
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"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"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"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"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"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"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!
Toggle word wrap
Toggle overflow
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"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"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"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"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"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"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"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!
Toggle word wrap
Toggle overflow
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"}]'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"}]'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!
Toggle word wrap
Toggle overflow
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 Team0nmcli con add type ethernet con-name Team0-port1 ifname enp1s0 slave-type team master Team0nmcli con add type ethernet con-name Team0-port1 ifname enp1s0 slave-type team master Team0nmcli con add type ethernet con-name Team0-port1 ifname enp1s0 slave-type team master Team0nmcli con add type ethernet con-name Team0-port1 ifname enp1s0 slave-type team master Team0nmcli 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!
Toggle word wrap
Toggle overflow
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 Team0nmcli con add type ethernet con-name Team0-port2 ifname enp2s0 slave-type team master Team0nmcli con add type ethernet con-name Team0-port2 ifname enp2s0 slave-type team master Team0nmcli con add type ethernet con-name Team0-port2 ifname enp2s0 slave-type team master Team0nmcli con add type ethernet con-name Team0-port2 ifname enp2s0 slave-type team master Team0nmcli 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!
Toggle word wrap
Toggle overflow
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
nmcli connection up Team0-port1
~]$ nmcli connection up Team0-port1nmcli 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-port2nmcli 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!
Toggle word wrap
Toggle overflow
Alternatively, issue a command to open the team as follows:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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 Team0nmcli 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 Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
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!
Toggle word wrap
Toggle overflow
To view one of the included files, such as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
Create a working configurations directory to store
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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!
Toggle word wrap
Toggle overflow
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!
Toggle word wrap
Toggle overflow
Make any necessary changes and save the file. See the
root
privileges. To list the available example configurations, enter the following command:
activebackup_ethtool_1.conf
, enter the following command:
teamd
configuration files. For example, as normal user, enter a command with the following format:
mkdir ~/teamd_working_configs
~]$ mkdir ~/teamd_working_configsmkdir ~/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.confcp /usr/share/doc/teamd-*/example_configs/activebackup_ethtool_1.conf \ ~/teamd_working_configs/activebackup_ethtool_1.confcp /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.confvi ~/teamd_working_configs/activebackup_ethtool_1.confvi ~/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!
Toggle word wrap
Toggle overflow
In this example we see that both the interfaces we plan to use are
“UP”.
To take down an interface, issue a command as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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!
Toggle word wrap
Toggle overflow
Then issue a command in the following format:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
The
root
user, change to the working configurations directory (teamd_working_configs in this example):
cd /home/userteamd_working_configs
~]# cd /home/userteamd_working_configscd /home/userteamd_working_configscd /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!
Toggle word wrap
Toggle overflow
root
:
To apply an address to the network team interface, team0, issue a command as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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!
Toggle word wrap
Toggle overflow
To activate the team interface, or to bring it “up”, issue a command as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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!
Toggle word wrap
Toggle overflow
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!
Toggle word wrap
Toggle overflow
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!
Toggle word wrap
Toggle overflow
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 Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To create a networking team using
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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:
master
.
To create a port to be a member of team0, create one or more files in the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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:
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!
Toggle word wrap
Toggle overflow
To view the network team, issue the following command:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
root
:
ifup team0
~]# ifup team0
ip link show
~]$ ip link show
8.10.4. Add a Port to a Network Team Using iputils Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To add a port em1 to a network team team0, using the ip utility, issue the following commands as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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 Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To view or list the ports in a network team, using the teamnl utility, issue the following command as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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 Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To view or list all currently available options, using the teamnl utility, issue the following command as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
To configure a team to use active backup mode, issue the following command as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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 Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To add an address to a team team0, using the ip utility, issue the following command as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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 Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To activate or “open” an interface to a network team, team0, using the ip utility, issue the following command as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
root
:
ip link set team0 up
~]# ip link set team0 up
8.10.9. Viewing the Active Port Options of a Team Using teamnl Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To view or list the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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 Copia collegamentoCollegamento copiato negli appunti!
Copia collegamentoCollegamento copiato negli appunti!
To set the
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
To check the change in team port options, issue the following command as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
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