Rhel7/centos7 Configure Network Teaming
The network teaming can federate or merge physical networking interfaces to form logical network interfaces with higher throughput or redundancy. It appears as an alternative to the NIC binding, which coexists with the traditional bonding mode in the system.
1. System environment
[[Email protected] ~]# uname -a[[email protected] ~]# uname -alinux test03 3.10.0-327.el7.x86_64 #1 &NBSP;SMP&NBSP;THU&NBSP;NOV&NBSP;19&NBSP;22:10:57&NBSP;UTC 2015 x86_64 x86_64 x86_64 GNU/Linux[[email protected] ~]# ip Addr show 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 forever2: eno16777736: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast&nbsP;STATE&NBSP;UP&NBSP;QLEN&NBSP;1000&NBSP;&NBSP;&NBSP;&NBSP;LINK/ETHER&NBSP;00:0C:29:56:69:4D&NBSP;BRD&NBSP;FF: Ff:ff:ff:ff:ff inet 192.168.231.13/24 brd 192.168.231.255 scope global eno16777736 valid_lft forever preferred_ lft forever inet6 fe80::20c:29ff:fe56:694d/64 scope link valid_lft forever preferred_lft forever3: eno33554992: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast State up qlen 1000 link/ether 00:0c:29:56:69:57 brd ff:ff : Ff:ff:ff:ff4: eno50332216: <broadcast,multicast,up,lower_up> mtu 1500 qdisc pfifo_fast state up qlen 1000 link/ether 00:0c : 29:56:69:61 brd ff:ff:ff:ff:fF:ff
2. Dual NIC binding target
3. Double-NIC Binding Step 3.1 View the physical NIC information:
[[email protected] network-scripts]# NMCLI device device TYPE State CONNECTION eno16777736 Ethernet con nected eno16777736 eno33554992 Ethernet connected eno33554992 eno50332216 Ethernet Connected eno50332216 Lo Loopback unmanaged--# A total of four network cards, Lo is the local loopback network card, the other three is a physical network card.
3.2 Viewing NIC connection information
[[email protected] network-scripts]# NMCLI connection show NAME UUID TYPE DEVICE eno50332216 36b38556-4bf8-4ce0-8045-4f5465530f67 802-3-ethernet eno50332216 eno33554992 46831ccf-905b- 4361-b5ba-c5448133e288 802-3-ethernet eno33554992 eno16777736 613db14a-2375-4a89-b55a-d2abd8fc65d5 802-3-ethernet en o16777736
3.3 Removing NIC connection information
In this network teaming configuration, need to be eno33554992
and eno50332216
bound to team0
, and set as the eno33554992
main network card, the first two network cards need the existing configuration information, or team0
after the creation is complete, the network card configuration information will affect team0
the normal work.
If nmcli connection show
there are no NIC connection information to be configured in the command output, no deletion is required.
[[email protected] network-scripts]# nmcli connection delete eno33554992 [[ email protected] network-scripts]# nmcli connection delete eno50332216 [[ Email protected] network-scripts]# [[email protected] network-scripts]# nmcli connection show NAME UUID TYPE device eno16777736 613db14a-2375-4a89-b55a-d2abd8fc65d5 802-3-ethernet eno16777736 # The NIC connection information was removed successfully. # here is actually the/etc/sysconfig/network-scripts directory of two network card configuration files. [[Email protected] network-scripts]# pwd/etc/sysconfig/network-scripts[[email protected] network-scripts]# ls ifcfg-*ifcfg-eno16777736 ifcfg-lo
3.4 Creating TEAM0
[[email protected] network-scripts]# NMCLI connection Add type TEAM ifname team0 con-name team0 config ' {"runner": {"name" : "Activebackup"}} ' ip4 192.168.231.100/24connection ' team0 ' (DFE2F884-40E0-4686-A7F9-2BE4B1A4B5B2) successfully Added.
Device type: Team; device name and connection name: all TEAM0; Binding mode: Activebackup-main standby mode; IP and subnet mask: 192.168.231.100/24;
Of course, you can also set the IP address later, example:
#创建team0并设置为主备模式 [[email protected] network-scripts]# NMCLI connection Add type TEAM ifname team0 con-name team0 config ' {" Runner ": {" name ":" Activebackup "}} ' #设置IP地址及子网掩码 [[email protected] network-scripts]# NMCLI Connection Modify Team0 ipv4.addresses 192.168.231.100/24# Set IP address get method to manual [[email protected] network-scripts]# NMCLI Connection Modify Team0 Ipv4.method Manual
After the configuration is complete, the IFCFG-TEAM0 configuration file is generated in the/etc/sysconfig/network-scripts directory
[[email protected] network-scripts]# cat/etc/sysconfig/network-scripts/ifcfg-team0 device=team0team_config= "{\" Runner\ ": {\" name\ ": \" Activebackup\ "}}" devicetype=teambootproto=nonedefroute=yesipv4_failure_fatal=noipv6init= Yesipv6_autoconf=yesipv6_defroute=yesipv6_failure_fatal=noname=team0uuid= dfe2f884-40e0-4686-a7f9-2be4b1a4b5b2onboot=yesipaddr=192.168.231.100prefix=24ipv6_peerdns=yesipv6_peerroutes= Yes
3.5 Add two NIC into Team0
# add Nic eno33554992, device type: team-slave; connection name: TEAM0-P1;MASTER:TEAM0; priority:100[[email protected] network-scripts]# nmcli connection add type team-slave ifname eno33554992 con-name team0-p1 master team0 config ' {"Prio": 100} ' connection ' Team0-p1 ' (4C8901C7-0246-47CE-8D5A-272F23F88D70) successfully added.# add Nic eno50332216, Device type: team-slave; connection name: TEAM0-P1;MASTER:TEAM0; priority:-10; Sticky bit: true (Sticky flag please set according to actual needs) [[email protected] network-scripts]# nmcli connection add type team-slave ifname eno50332216 con-name team0-p2 master team0 config ' {"Prio": -10, "sticky": true} ' connection ' Team0-p2 ' (d898f1f5-bb0f-496e-8cdd-7f3898c2a482) successfully added.
In this configuration eno33554992
, the main network card, set its priority is the second eno50332216
network card, set its priority to 10, sticky bit is true.
Prio: Priority.
The higher the number, the higher the priority of the network card, the priority is the active network card; If the priority is not set, the default is 0, the network card is the active NIC, the other one is the backup network card, until the active network card disconnects, the backup network card automatically upgraded to active network card, two network card role interchange.
Sticky: Sticky bit, default is false;
The eno50332216
sticky is set to true in the secondary network card, which means that if the secondary NIC connection status becomes active, it will remain active regardless of whether the primary NIC connection is normal.
If the sticky is not set, when the secondary network card is active, if the primary network card connection is back to normal, then the active network card is taken over by the primary network card, and the secondary network card becomes the backup state.
Parameters can be set according to the actual needs.
After the configuration is complete, the IFCFG-TEAM0-P1,IFCFG-TEAM0-P2 configuration file is generated in the/etc/sysconfig/network-scripts directory:
[[email protected] network-scripts]# cat ifcfg-team0-p1team_port_config= "{\" prio\ ":" Name=team0-p1uuid= 4c8901c7-0246-47ce-8d5a-272f23f88d70device=eno33554992onboot=yesteam_master=team0devicetype=teamport[[email Protected] network-scripts]# cat ifcfg-team0-p2team_port_config= "{\" prio\ ": -10,\" sticky\ ": true}" Name=team0-p2uuid =d898f1f5-bb0f-496e-8cdd-7f3898c2a482device=eno50332216onboot=yesteam_master=team0devicetype=teamport
4. Activating the TEAM0 and its sub-network card
# activate TEAM0-P1 [[email protected] ~]# NMCLI connection up TEAM0-P1 connection successfully activated (D-bus active path:/or G/FREEDESKTOP/NETWORKMANAGER/ACTIVECONNECTION/5) # Activate Team0-p2[[email protected] ~]# NMCLI connection up Team0-p2connection successfully activated (D-bus active path:/ORG/FREEDESKTOP/NETWORKMANAGER/ACTIVECONNECTION/6) # Activate Team0[[email protected] ~]# NMCLI connection up team0connection successfully activated (master waiting for slaves) (D-bu S active path:/ORG/FREEDESKTOP/NETWORKMANAGER/ACTIVECONNECTION/7)
5. TEAM0 Status View 5.1 view TEAM0 working status:
# view current active NIC [[email protected] network-scripts]# nmcli connection show -- active name uuid TYPE DEVICE team0-p1 4c8901c7-0246-47ce-8d5a-272f23f88d70 802-3-ethernet eno33554992 eno16777736 613db14a-2375-4a89-b55a-d2abd8fc65d5 802-3-ethernet eno16777736 team0 d6e07840-dff8-49e9-a23c-35eb0cc0ec4b team team0 team0-p2 d898f1f5-bb0f-496e-8cdd-7f3898c2a482 802-3-ethernet eno50332216 #查看team0端口状态 [[email protected] network-scripts]# teamnl team0 ports 4: eno50332216: up 1000Mbit FD 3: eno33554992: up 1000Mbit FD [[Email protected] network-scripts]# teamdctl team0 statsetup: runner: activebackupports: eno33554992 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up eno50332216 link watches: link summary: up instance[link_watch_0]: &nbSp;name: ethtool link: uprunner: active port: eno33554992
5.2 View Team0 Detailed configuration
# View team0 Detailed configuration [[email protected] network-scripts]# teamdctl team0 config dump{ "Device": "Team0", "Mcast_rejoin": { "Count": 1 }, "Notify_ Peers ": { " Count ": 1 }, "Ports": { "eno33554992": { "Link_watch": { "name": "Ethtool" }, "Prio": 100 }, "eno50332216": { "link_ Watch ": { "Name": "Ethtool" }, "Prio": -10, "sticky": true } }, "Runner": { "name": "Activebackup" }}# separate view team0 sub-NIC details configuration [[email protected] network-scripts]# teamdctl team0 port config dump eno33554992{ "Link_watch": { "name": "Ethtool" }, "Prio": 100}[[email protected] network-scripts]# teamdctl team0 port config dump eno50332216{ "Link_watch": { "name": "Ethtool" }, "Prio": -10, "sticky": true}
6. TEAM0 Switch Test
[Email protected] ~]# teamdctl team0 stat setup:runner:activebackupports:eno33554992 link Watches:link summ Ary:up Instance[link_watch_0]: Name:ethtool link:up eno50332216 link Watches:link Summary: Up Instance[link_watch_0]: Name:ethtool link:uprunner:active port:eno33554992
The current active sub-network card is eno33554992
, ping Team0 's IP address can always ping through. Now disconnect the NIC:
# disconnecting the TEAM0-P1 network connection [[EMAIL&NBSP;PROTECTED]&NBSP;~]#&NBSP;NMCLI&NBSP;CONNECTION&NBSP;DOWN&NBSP;TEAM0-P1 Connection ' Team0-p1 ' successfully deactivated (d-bus active path: / ORG/FREEDESKTOP/NETWORKMANAGER/ACTIVECONNECTION/2) # View TEAM0 connection Status [[email protected] ~]# teamdctl team0 stat setup: runner: activebackupports: eno50332216 link watches: link summary: up instance[link_watch_0]: name: ethtool link: uprunner: active port: eno50332216 # active NIC becomes eno50332216,ping test after a brief interruption to recovery. Reply from 192.168.231.100 : byte =32 time <1ms ttl=64 reply from 192.168.231.100 : Byte =32 time <1ms ttl=64 from 192.168.231.100 reply: byte =32 time =1ms ttl=64 reply from 192.168.231.100 : bytes =32 time <1ms ttl=64 Request timed out. The request timed out. Reply from 192.168.231.100 : bytes =32 time =1ms ttl=64 from 192.168.231.100 reply: bytes = 32 time <1ms ttl=64 reply from 192.168.231.100 : bytes =32 time <1ms ttl=64
Because this test is performed in a virtual machine, the ping test will have a more significant interruption, and when tested on a real physical machine, the ping test will continue to be normal or resume after a brief outage.
Official documents recommended to use: nmcli device [disconnect|connect] ifname
command to disconnect and connect the network card, but after using this method on the virtual machine to disconnect the network card connection, the recovery network card connection will be error, here Use the command nmcli connection [down|up] ifname
to operate.
Current active network card as a secondary network card eno50332216
, now connect the main network card:
# Restore the TEAM0-P1 network connection [[email protected] ~]# nmcli connection up team0-p1 connection successfully activated (d-bus active path: /org/freedesktop/ NETWORKMANAGER/ACTIVECONNECTION/7) # View the connection status of Team0 [[Email protected] ~]# teamdctl team0 stat setup: runner: activebackupports: eno33554992 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up eno50332216 link watches: link summary: up instance[link_watch_0]: name: ethtool link: uprunner: active port: eno50332216# ping recovery from 192.168.231.100 after a brief interruption of the test Reply: byte =32 time <1ms ttl=64 request timed out. The request timed out. Reply from 192.168.231.100 : bytes =32 time =1ms ttl=64 from 192.168.231.100 reply: bytes = 32 Time <1ms ttl=64
Because this test is performed in a virtual machine, the ping test will have a more significant interruption, and when tested on a real physical machine, the ping test will continue to be normal or resume after a brief outage.
After the primary network card connection is back to normal, view Team0 found that the current active network card is still a supplement network card eno50332216
, the active network card is not switched to the main network card eno33554992
, because the secondary network card set the sticky bit sticky=true,sticky flag to make the secondary network card active state, If the network connection does not fail, it will remain active for the NIC.
If the sticky flag is not set in the secondary network adapter configuration, when the primary network connection is restored, the active network card is taken over by the primary network adapter and the secondary network card becomes the backup state.
7. Dual-NIC binding each mode configuration file example
For a variety of dual-NIC binding configuration modes, refer to the sample files in the system, file location:
/usr/share/doc/teamd-xx/example_configs/
This article is from the "Future People" blog, please be sure to keep this source http://zaa47.blog.51cto.com/6181689/1925126
RHEL7/CENTOS7 dual NIC binding-network Teaming