聚合链路(网卡绑定)的配置

聚合链路的主要作用:备份网卡,防止单点故障,在一块网卡故障的情况下,自动启用第二块网卡。

    ——热备份(activebackup),连接冗余

1、首先要存在两块及以上的网卡设备

eth1: flags=4163  mtu 1500
        ether 52:54:00:f8:86:c1  txqueuelen 1000  (Ethernet)
        RX packets 4934  bytes 272982 (266.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

eth2: flags=4163  mtu 1500
        ether 52:54:00:38:79:d9  txqueuelen 1000  (Ethernet)
        RX packets 4937  bytes 273272 (266.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2、创建虚拟网卡team0

[root@server0 ~]# nmcli connection add type team con-name team0 ifname team0 autoconnect yes config '{"runner": {"name" : "activebackup"}}'
Connection 'team0' (dd59fba1-9719-433a-ab44-ba0b38fb08b6) successfully added.

3、添加team0成员(网卡设备)

[root@server0 ~]# nmcli connection add type team-slave con-name team0-1 ifname eth1 master team0
Connection 'team0-1' (406dd316-98be-4a3d-b8d7-249e4992220b) successfully added.
[root@server0 ~]# nmcli connection add type team-slave con-name team0-2 ifname eth2 master team0 
Connection 'team0-2' (d0c0b497-7409-4cd6-87ae-f4c2be2aa545) successfully added.

4、配置team0网卡ip

[root@server0 ~]# nmcli connection modify team0 ipv4.method manual ipv4.addresses 192.168.1.1/24 connection.autoconnect yes

5、激活所有配置

[root@server0 ~]# nmcli connection up team0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
[root@server0 ~]# nmcli connection up team0-1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
[root@server0 ~]# nmcli connection up team0-2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)

测试通信:

在另一台设备上按照上述步骤配置好一个ip为192.168.1.2的聚合链路,测试是否能够通信;关闭一块正在运行的网卡,再测试是否能够通信,如果都能够通信则配置成功。

[root@desktop0 ~]# ping -c 3 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.393 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.408 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.553 ms

--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.393/0.451/0.553/0.074 ms
[root@server0 ~]# ifconfig eth1 down
[root@server0 ~]# teamdctl team0 state
setup:
  runner: activebackup
ports:
  eth1
    link watches:
      link summary: down
      instance[link_watch_0]:
        name: ethtool
        link: down
  eth2
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
runner:
  active port: eth2
[root@desktop0 ~]# ping -c 3 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_seq=1 ttl=64 time=0.285 ms
64 bytes from 192.168.1.1: icmp_seq=2 ttl=64 time=0.300 ms
64 bytes from 192.168.1.1: icmp_seq=3 ttl=64 time=0.529 ms

--- 192.168.1.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.285/0.371/0.529/0.112 ms




你可能感兴趣的:(engineer)