Now let's configure the network card binding in CentOS 7 and run the ip link command to view the available network cards
[root@localhost ~]# ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 08:00:27:7b:d3:32 brd ff:ff:ff:ff:ff:ff 3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000 link/ether 08:00:27:81:d3:be brd ff:ff:ff:ff:ff:ff
Here, two network cards, enp0s3 and enp0s8, are used to configure the link aggregation of the active and standby modes.
Create Team interface
[root@localhost ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}' Connection 'team0' (4df78635-b9fc-4539-ab02-27db11c656fe) successfully added.
Run nmcli con show to view the configuration of team0
[root@localhost ~]# nmcli con show NAME UUID TYPE DEVICE team0 4df78635-b9fc-4539-ab02-27db11c656fe team team0 enp0s3 5005942f-a7fd-4e55-b8e7-77928d8da72d ethernet enp0s3 Wired connection 1 45dee64a-53b3-3e2a-b2d4-e377f3e668a2 ethernet enp0s8
Add Slave interface
Here, two network cards, enp0s3 and enp0s8, are used as the slave interface of team0:
[root@localhost ~]# nmcli connection add type team-slave con-name team0-port1 ifname enp0s3 master team0 Connection 'team0-port1' (15183c4a-2053-4b53-ad58-de5a07ae3ae9) successfully added. [root@localhost ~]# nmcli connection add type team-slave con-name team0-port2 ifname enp0s8 master team0 Connection 'team0-port2' (a34e20b0-3422-46e5-a947-bb2eaa6c0622) successfully added.
To view port configuration information:
[root@localhost ~]# nmcli connection show NAME UUID TYPE DEVICE team0 4df78635-b9fc-4539-ab02-27db11c656fe team team0 enp0s3 5005942f-a7fd-4e55-b8e7-77928d8da72d ethernet enp0s3 Wired connection 1 45dee64a-53b3-3e2a-b2d4-e377f3e668a2 ethernet enp0s8 team0-port1 15183c4a-2053-4b53-ad58-de5a07ae3ae9 ethernet -- team0-port2 a34e20b0-3422-46e5-a947-bb2eaa6c0622 ethernet --
Assign IP address
Assign a static IP address to team0 and start team0 configuration:
[root@localhost ~]# nmcli connection modify team0 ipv4.method manual ipv4.addresses 192.168.0.200/24 ipv4.gateway 192.168.0.1 ipv4.dns 202.102.128.68 # nmcli connection down team0 close interface [root@localhost ~]# nmcli connection up team0 Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
Check the connection configuration information and find that team0-port1 is not bound to the network interface enp0s3
This is because the ifcfg-team0-port1 configuration file and ifcfg-enp0s3 configuration file are both set to boot
So we need to turn off the startup of enp0s3. Here we turn off the startup of enp0s3 and Wired connection 1.
[root@localhost ~]# nmcli connection modify enp0s3 autoconnect no [root@localhost ~]# nmcli connection modify Wired\ connection\ 1 autoconnect no
Then restart the network service to view the link configuration:
[root@localhost ~]# systemctl restart network [root@localhost ~]# nmcli connection [root@localhost ~]# ip ad
You can see that both team0-port1 and team0-port2 are bound to the corresponding network card. The ip address of team0 is 192.168.0.200 set manually
Verification
To view the status of team0:
[root@localhost ~]# teamdctl team0 state setup: runner: activebackup ports: enp0s3 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 enp0s8 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 runner: active port: enp0s8
Now the active port is enp0s8. Let's disconnect this port and see if the active standby mode configuration works:
[root@localhost ~]# nmcli device disconnect enp0s8 Device 'enp0s8' successfully disconnected. [root@localhost ~]# teamdctl team0 state setup: runner: activebackup ports: enp0s3 link watches: link summary: up instance[link_watch_0]: name: ethtool link: up down count: 0 runner: active port: enp0s3
See that the active interface is switched to the top of enp0s3.
Other team port aggregation modes
##Configure primary standby mode, similar to bond mode=1 nmcli connection add type team ifname team0 con-name team0 config '{"runner": {"name": "activebackup"}}' ##If the lacp is configured to pass 802.3ad mode, the switch needs to bind the lacp, similar to bond mode=4 nmcli connection add type team ifname team0 con-name team0 config '{"runner": {"name": "lacp"}}' ##Broadcast mode: the traffic is randomly sent out through all team interfaces, similar to bond mode=3 nmcli connection add type team ifname team0 con-name team0 config '{"runner": {"name": "broadcast"}}' ##In round robin mode, packets are sent out from team interface one by one in order, similar to bond mode=0 nmcli connection add type team ifname team0 con-name team0 config '{"runner": {"name": "roundrobin"}}' ##Load balancing mode: according to the load balancing algorithm, choose the wrong port to send out the contract nmcli connection add type team ifname team0 con-name team0 config '{"runner": {"name": "loadbalance"}}'
Other relevant knowledge points
Refer to the summary of Niu Ren: https://www.cnblogs.com/duzhaoqi/p/7491761.html
-
About network interface naming
Before CentOS 6, network interfaces were named with consecutive numbers: eth0, eth1, etc. when adding or deleting network cards, the names might change. CentOS 7 uses hardware based, device topology, and setting type naming. -
Naming mechanism of network card
System D's naming method for network devices
(a) If the index information provided by Firmware or BIOS for the devices integrated on the motherboard is available and predictable, name them according to this index, such as eno1 (b) If the index information provided by Firmware or BIOS for PCI-E expansion slot is available and predictable, name it according to this index, such as ens1 (c) If the physical location information of the hardware interface is available, name it according to this information, for example, enp2s0 (d) If the user explicitly starts, it can also be named according to the MAC address, enx2387a1dc56 (e) When none of the above is available, the traditional naming mechanism is used
- NIC name
(1) Enable biosdevname software based on BIOS support
Built in network card: em1,em2 pci card: pYpX Y: slot ,X: port
(2) Name composition format
en: Ethernet wired LAN wl: wlan ww: wwan
- Name type:
o<index>: Device index number of integrated device s<slot>: Index number of expansion slot x<MAC>: Be based on MAC Name of address p<bus>s<slot>: enp2s1
- Naming process of network card device
Step one:
Udev, helper / lib/udev/rename_device According to / usr/lib/udev/rules.d/60-net.rules
The second step:
biosdevname Will be based on/usr/lib/udev/rules.d/71-biosdevname.rules
The third step:
By detecting the network interface device, according to the /usr/lib/udev/rules.d/75-net-description ID_NET_NAME_ONBOARD ID_NET_NAME_SLOT ID_NET_NAME_PATH