配置链路聚合

链路聚合配置

实验环境:VMware Workstation 虚拟机 CentOS7

1.关闭虚拟机,点击编辑虚拟机设置,选择网络适配器添加两块网卡

ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 192.168.76.129  netmask 255.255.255.0  broadcast 192.168.76.255
    inet6 fe80::a53:e69f:592f:ff95  prefixlen 64  scopeid 0x20<link>
    ether 00:0c:29:57:cb:50  txqueuelen 1000  (Ethernet)
    RX packets 15  bytes 4129 (4.0 KiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 25  bytes 4351 (4.2 KiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens38: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
    inet 192.168.76.128  netmask 255.255.255.0  broadcast 192.168.76.255
    inet6 fe80::2dd5:dc0c:d694:c9f6  prefixlen 64  scopeid 0x20<link>
    ether 00:0c:29:57:cb:5a  txqueuelen 1000  (Ethernet)
    RX packets 19  bytes 4415 (4.3 KiB)
    RX errors 0  dropped 0  overruns 0  frame 0
    TX packets 21  bytes 4065 (3.9 KiB)
    TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

2.配置聚合网卡

生成网卡连接,设置主备模式
  
  网卡模式有:broadcast、roundrobin、activebackup、loadbalance、lacp
nmcli connection add type team con
-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}' Connection 'team0' (d908400b-42d2-4b00-8b21-8bd1bb70e3bf) successfully added. nmcli connection modify team0 ipv4.method manual ipv4.addresses '192.168.76.10/24' ipv4.gateway 192.168.76.1 ipv4.dns 8.8.8.8 配置网卡IP地址信息

3.添加子网卡

nmcli connection add type team-slave con-name team0-port1 ifname ens37 master team0     第一块添加的网卡将会成为主网卡,直接是活动状态

    Connection 'team0-port1' (16111bb4-29cc-4b81-a82e-aedbba7a4ea5) successfully added.

nmcli connection add type team-slave con-name team0-port2 ifname ens38 master team0     第二块添加的网卡将会成为备份网卡,

    Connection 'team0-port2' (fc400c01-0c74-4933-821e-40098cfab088) successfully added.

4.激活网卡

nmcli connection up team0

    Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6)

5.查看聚合网卡状态

nmcli connection show team0

teamdctl team0 state

    setup:
        runner: activebackup
    ports:
        ens38
            link watches:
            link summary: up
            instance[link_watch_0]:
                name: ethtool
                link: up
                down count: 0
        ens37
            link watches:
            link summary: up
            instance[link_watch_0]:
            name: ethtool
            link: up
            down count: 0
    runner:
        active port: ens

6.测试网卡可靠性

ping -I team0 192.168.76.10     测试可通

nmcli  dev dis  eno37           卸掉主备网卡中的主网卡

teamdctl team0 state            可以看到备份网卡自动成为主网卡

    setup:
        runner: activebackup
    ports:
        ens38
            link watches:
            link summary: up
            instance[link_watch_0]:
                name: ethtool
                link: up
                down count: 0
    runner:
        active port: ens38

ping -I team0 192.168.76.10     测试可通
原文地址:https://www.cnblogs.com/cq146637/p/8321983.html