linux network articles
Article Directory
Aggregation is divided into network aggregation and link aggregation
- Network aggregation: integrate multiple local area networks into one local area network for unified deployment and management, the large second-tier technology VXLAN in the network.
- Link aggregation: Bundle multiple network card links to form a logical link, which can be load sharing or active/standby switching.
One, link aggregation
-
The link aggregation of the network card is to connect multiple network cards. When one network card is damaged, the network can still operate normally, which can effectively prevent the loss caused by the damage of the network card and also improve the network access speed.
-
The link aggregation method of the network card:
1. bond: up to two network cards can be added;
2. team: up to eight network cards can be added -
Two commonly used bond modes:
- 1, bond0 (balance-rr)
bond0 is used for load polling (2 networks are 100MB individually, and the aggregated network is 1 network with a transmission bandwidth of 200MB) - 2. bond1 (active-backup)
bond1 is used for high availability. If one of the lines is disconnected, the other lines will be automatically backed up and switched for use
- 1, bond0 (balance-rr)
Second, the configuration of link aggregation
1, Centos7/RHEL7 configuration bond aggregation link
-
1 Centos7/RHEL7配置bond0
[root@wangqing ~]# nmcli device
-
//创建bond0, 模式为balance-rr
[root@wangqing ~]# nmcli connection add type bond mode balance-rr con-name bond0 ifname bond0 ipv4.method manual ipv4.addresses 172.16.12.250/24 ipv4.gateway 172.16.12.2 ipv4.dns 172.16.12.2
Connection ‘bond0’ (83b7b2c9-fd9f-45e4-b6aa-512774cc6808) successfully added.
-
//添加物理网卡连接至bond0
[root@wangqing ~]# nmcli connection add type bond-slave con-name bond-slave0 ifname eth0 master bond0
Connection ‘bond-slave0’ (5642affa-217d-4e48-ac6c-6043f1657361) successfully added.
[root@wantqing ~]# nmcli connection add type bond-slave con-name bond-slave1 ifname eth1 master bond0
Connection ‘bond-slave1’ (1ef9017f-4b0d-46bf-95a1-f31be9353234) successfully added.
-
//View bond configuration information
[root@wangqing ~]# cat /proc/net/bonding/bond0
-
//Close the eth0 network card and test whether bond0 is normal
[root@wangqing ~]# nmcli device disconnect eth0
-
2. Centos6/RHEL6 configure bond aggregation link (because 6 does not have nmcli command tool)
- Suitable for RedHat6 and CentOS6
system | Network card | bond address | bond mode | bond function |
---|---|---|---|---|
Centos6.5 | eth0: | 172.16.12.128 | 172.16.12.250 | Mode 0 |
eth1: 172.16.12.129 |
-
//1. Create binding network card configuration file
-
[root@wangqing ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0
-
BONDING_OPTS="mode=0 miimon=50" //If you use mode 1, change the mode to 1
-
-
//2.修改eth0和eth1网卡配置文件
[root@wangqing ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes
[root@wangqing ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
ONBOOT=yes
USERCTL=no
BOOTPROTO=none
MASTER=bond0
SLAVE=yes -
//3. Add driver to support bond0
[root@wangqing ~]# vim /etc/modprobe.d/bonding.conf
alias bond0 bonding
3. Centos7/RHEL7 configuration team aggregation link
-
Centos/rhce7 uses teaming to implement aggregation links, which can provide network throughput performance after network card binding, and provide network card failover processing capabilities.
-
Team is based on a small kernel driver to implement aggregation links, and provides teamd commands at the user layer to implement link management.
-
teamd can realize the following modes of aggregation link
-
broadcast fault tolerance
-
roundrobin load polling: roundrobin scheduling, one by one.
-
activebackup (required)
-
loadbalance Load balancing: improve performance, increase throughput, run more with high performance, and run less with low performance.
lacp requires the switch to support the lacp protocol -
//Please use the command line configuration, the graphical interface configuration is unstable
[root@wangqing ~]# nmcli connection add type team con-name team0 ifname team0 config'{"runner":{"name":"activebackup"}}' ipv4 .addresses 172.16.12.250/24 ipv4.gateway 172.16.12.2 ipv4.dns 172.16.12.2 ipv4.method manual
Connection'team0' (cd90d0ee-b65e-488c-8fd2-85facb1d6868) successfully added.
-
//添加物理网卡连接至team0
[root@wangqing ~]# nmcli connection add type team-slave con-name team0-port1 ifname eth1 master team0
Connection ‘team-slave0’ (34873b23-60ff-42cf-bf65-77479bcd7369) successfully added.
[root@wangqing ~]# nmcli connection add type team-slave con-name team0-port2 ifname eth2 master team0
Connection ‘team-slave1’ (3cfc524f-cbf8-4039-b511-830b90a23726) successfully added.
-
//Check team0 state
[root@wangqing ~]# ping -I team0 172.16.12.128
[root@wangqing ~]# teamdctl team0 state
-
//Check after disconnection
[root@wangqing ~]# nmcli dev disconnect eth1
[root@wangqing ~]# teamdctl team0 state
Dynamically modify team mode
-
// Export configuration for modification (man teamd.conf)
[root@wangqing ~]# teamdctl team0 config dump> /tmp/team.conf
[root@wangqing ~]# vim /tmp/team.conf
//Modify with the latest Configuration options modify team0 properties
[root@wangqing ~]# nmcli con mod team0 team.config /tmp/team.conf
//You need to restart team0 after modification
[root@wangqing ~]# nmcli connection down team0; nmcli connection up team0
[root @wangqing ~]# nmcli connection up team0-port1
[root@wangqing ~]# nmcli connection up team0-port2 -
The first step is to export the configuration of the team, (the process screenshot is as follows) the
second step, and then modify the mode of the configuration file.
The third step is to import the configuration file into the team network card configuration. The
fourth step is to restart the team network card device (must restart, otherwise the device will not take effect), and finally check the device information.
-