Use nmcli to configure the NIC aggregation link in CentOS 7
The CentOS7 series greatly changes the configuration of multiple NICs. The following are the configuration notes based on the actviebackup properties of the RECL-7.0 series.
[Root @ server0 ~] # Nmcli con show // The blue-bold Nic is the NIC configured in this example.
NAME UUID TYPE DEVICE
Ethernet connection 2 8afe67cc-20ef-4985-86c3-b8d3c9371fc9 802-3-ethernet ens34
Ethernet connection 3 0cf045a5-012c-46bd-9367-1139666871b5 802-3-ethernet ens35
Eth0 ff18a078-5b66-4bb8-8bba-fafd426b9d39 802-3-ethernet ens32
# Create a Link Interface named team0 and whose attribute is team
[Root @ server0 ~] # Nmcli con add type team con-name team0 ifname team0 config '{"runner": {"name": "activebackup "}}'
# Configure the IP address and gateway for team0
[Root @ server0 ~] # Nmcli connection modify team0 255.4.addresses "192.168.25.211/24 192.168.25.250"
# Configure DNS for team0
[Root @ server0 ~] # Nmcli connection modify team0 ipv4.dns "192.168.10.86 192.168.10.87"
# Set the team0 attribute to manual
[Root @ server0 ~] # Nmcli connection modify team0 ipv4.method manual
# Add the ent34 Nic port to the team0 Interface
[Root @ server0 ~] # Nmcli connection add type team-slave conn-name team-port1 ifname ens34 master team0
# Add the ent35 Nic port to the team0 Interface
[Root @ server0 ~] # Nmcli connection add type team-slave conn-name team-port2 ifnameens35master team0
# Enable the NIC in the interface
[Root @ server0 ~] # Nmcli connection up team-port1; nmcli connection up team-port2
Connection successfully activated (D-Bus active path:/org/freedesktop/NetworkManager/ActiveConnection/25)
Connection successfully activated (D-Bus active path:/org/freedesktop/NetworkManager/ActiveConnection/26)
[Root @ server0 ~] # Teamdctl team0 state view
Setup:
Runner: activebackup
Ports:
Ens34
Link watches:
Link summary: up
Instance [link_watch_0]:
Name: ethtool
Link: up
Ens35
Link watches:
Link summary: up
Instance [link_watch_0]:
Name: ethtool
Link: up
Runner:
Active port: ens34 // main interface of current team0
[Root @ server0 ~] # Ifconfig team0
Team0: flags = 4163 <UP, BROADCAST, RUNNING, MULTICAST> mtu 1500
Inet 192.168.25.211 netmask 255.255.255.0 broadcast 192.168.25.255
Inet6 fe80: 20c: 29ff: fea7: 34b prefixlen 64 scopeid 0x20 <link>
Ether 00: 0c: 29: a7: 03: 4b txqueuelen 0 (Ethernet)
RX packets 55 bytes 4477 (4.3 KiB)
RX errors 0 dropped 70 overruns 0 frame 0
TX packets 61 bytes 8297 (8.1 KiB)
TX errors 0 dropped 9 overruns 0 carrier 0 collisions 0
[Root @ server0 ~] # Teamnl team0 ports
4: ens35: up 1000 Mbit FD
3: ens34: up 1000 Mbit FD
[Root @ server0 ~] # Teamnl team0 options
Queue_id (port: ens35) 0
Priority (port: ens35) 0
User_linkup_enabled (port: ens35) false
User_linkup (port: ens35) true
Enabled (port: ens35) true
Queue_id (port: ens34) 0
Priority (port: ens34) 0
User_linkup_enabled (port: ens34) false
User_linkup (port: ens34) true
Enabled (port: ens34) true
Mcast_rejoin_interval 0
Mcast_rejoin_count 0
Notify_peers_interval 0
Policy_peers_count 0
Mode roundrobin
Test
Open a ping window and disable one of the NICS in team0
========================================================== =====
[Root @ server0 ~] # Nmcli device disconnect ens34
Tips: in principle, one packet of ping data won't be dropped.