配置链路聚合

1. 检查 system 的网卡,有 2 个空闲的网卡,记下他们的名称 

[root@server101 ~]# nmcli device
DEVICE TYPE STATE CONNECTION
br0 bridge connected Bridge eno16777736
eno16777736 ethernet connected System eno16777736
eno33554960 ethernet disconnected --
eno50332184 ethernet disconnected --
lo loopback unmanaged --

2. 创建一个连接 ID 为 team1,类型为 team,接口为 TEAM1(后面会创建),team 配置为 “activebackup” 

[root@server101 ~]# nmcli connection add con-name team1 type team ifname TEAM1 config '{"runner": {"name":"activebackup"}}'
Connection 'team1' (91d58e94-9108-49f0-99b5-3ac9898252aa) successfully added.
[root@server101 ~]#

 3. 指定connection team1的IPv4地址为192.168.1.102/24,手动设置IPv4地址

[root@server101 ~]# nmcli connection modify team1 ipv4.addresses '192.168.1.101/24' ipv4.method manual

4. 指定connection team1的IPv6地址是2001:1::102/64,手动设置IPv6地址

[root@server101 ~]# nmcli connection modify team1 ipv6.addresses '2001:1::101/64' ipv6.method manual

5. 将第2个网卡加入TEAM1组接口

[root@server101 ~]# nmcli connection add type team-slave ifname eno33554960 master TEAM1
Connection 'team-slave-eno33554960' (f93e5de8-9819-45ed-945d-89eb74f455ee) successfully added.

6. 将第3个网卡加入TEAM1组接口

[root@server101 ~]# nmcli connection add type team-slave ifname eno50332184 master TEAM1
Connection 'team-slave-eno50332184' (93485ea2-d30a-4748-95b3-912e0576ca14) successfully added.

7. 检查现在网卡列表,有一个新的网卡TEAM1

[root@server101 ~]# nmcli device
DEVICE TYPE STATE CONNECTION
br0 bridge connected Bridge eno16777736
eno16777736 ethernet connected System eno16777736
eno33554960 ethernet connected team-slave-eno33554960
eno50332184 ethernet connected team-slave-eno50332184
TEAM1 team connected team1
lo loopback unmanaged --

8. 检查TEAM1网卡的ip地址,看到IPv4和IPv6地址

6: TEAM1: mtu 1500 qdisc noqueue state UP
link/ether 00:0c:29:16:3f:5d brd ff:ff:ff:ff:ff:ff
inet 192.168.1.101/24 brd 192.168.1.255 scope global TEAM1
valid_lft forever preferred_lft forever
inet6 2001:1::101/128 scope global
valid_lft forever preferred_lft forever
inet6 fe80::20c:29ff:fe16:3f5d/64 scope link
valid_lft forever preferred_lft forever

9. 确认现在你的系统可以ping192.168.1.254和2001:1::254

[root@server101 ~]# ping -c2 192.168.1.254
PING 192.168.1.254 (192.168.1.254) 56(84) bytes of data.
64 bytes from 192.168.1.254: icmp_seq=1 ttl=64 time=0.525 ms
64 bytes from 192.168.1.254: icmp_seq=2 ttl=64 time=1.10 ms

--- 192.168.1.254 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.525/0.813/1.102/0.289 ms
[root@server101 ~]# ping6 -c2 2001:1::101
PING 2001:1::101(2001:1::101) 56 data bytes
64 bytes from 2001:1::101: icmp_seq=1 ttl=64 time=0.039 ms
64 bytes from 2001:1::101: icmp_seq=2 ttl=64 time=0.065 ms

--- 2001:1::101 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.039/0.052/0.065/0.013 ms
[root@server101 ~]# 

10.  使用 teamdctl 检查 TEAM1 的状态,看到 2 个接口的 

[root@server101 ~]# teamdctl TEAM1 state
setup:
  runner: activebackup
ports:
  eno33554960
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
  eno50332184
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
runner:
  active port: eno33554960
[root@server101 ~]# 

11 关闭原先为 active 状态的接口,会看到另一个接口成为新的 active 接口 

[root@server101 ~]# nmcli device disconnect eno33554960 
[root@server101 ~]# teamdctl TEAM1 state
setup:
  runner: activebackup
ports:
  eno50332184
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
runner:
  active port: eno50332184
[root@server101 ~]# 

12 用 ip addr 检查 TEAM1 的 IP 地址,状态还是 UP 

[root@server101 ~]# ip addr show TEAM1
6: TEAM1:  mtu 1500 qdisc noqueue state UP 
    link/ether 00:0c:29:16:3f:5d brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.101/24 brd 192.168.1.255 scope global TEAM1
       valid_lft forever preferred_lft forever
    inet6 2001:1::101/128 scope global 
       valid_lft forever preferred_lft forever
    inet6 fe80::20c:29ff:fe16:3f5d/64 scope link 
       valid_lft forever preferred_lft forever

13 将 TEAM1 的配置文件导出 

[root@server101 ~]# teamdctl TEAM1 config dump > /tmp/team1.cfg
[root@server101 ~]# cat /tmp/team1.cfg 
{
    "device": "TEAM1",
    "mcast_rejoin": {
        "count": 1
    },
    "notify_peers": {
        "count": 1
    },
    "ports": {
        "eno33554960": {
            "link_watch": {
                "name": "ethtool"
            }
        },
        "eno50332184": {
            "link_watch": {
                "name": "ethtool"
            }
        }
    },
    "runner": {
        "name": "activebackup"
    }
}

14 编辑导出的配置文件,指定第一个网卡的优先级是 20,第二个网卡的优先级为 10 

[root@server101 ~]# vim /tmp/team1.cfg

{
    "device": "TEAM1",
    "mcast_rejoin": {
        "count": 1
    },
    "notify_peers": {
        "count": 1
    },
    "ports": {
        "eno33554960": {
                "prio": 20,
            "link_watch": {
                "name": "ethtool"
            }
        },
        "eno50332184": {
                "prio": 10,
            "link_watch": {
                "name": "ethtool"
            }
        }
    },
    "runner": {
        "name": "activebackup"
    }
}

15 重新加载配置文件

[root@server101 ~]# nmcli connection modify team1 team.config /tmp/team1.cfg

16 重新激活连接team1

[root@server101 ~]# nmcli connection up team1 
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/5)

17 检查TEAM1的配置文件,查看2个接口的优先级

[root@server101 ~]# teamdctl TEAM1 config dump
{
    "device": "TEAM1",
    "mcast_rejoin": {
        "count": 1
    },
    "notify_peers": {
        "count": 1
    },
    "ports": {
        "eno33554960": {
            "link_watch": {
                "name": "ethtool"
            },
            "prio": 20
        },
        "eno50332184": {
            "link_watch": {
                "name": "ethtool"
            },
            "prio": 10
        }
    },
    "runner": {
        "name": "activebackup"
    }
}

18 现在只要第一个接口是 UP 状态的,这个接口就会使 active (目前第一个接口没有启动)

[root@server101 ~]# teamdctl TEAM1 state
setup:
  runner: activebackup
ports:
  eno50332184
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
runner:
  active port: eno50332184
[root@server101 ~]# 

19 现在启动第一个接口,看看active port会不会变成第一个接口eno33554960

[root@server101 ~]# nmcli device connect eno33554960 
Device 'eno33554960' successfully activated with 'f93e5de8-9819-45ed-945d-89eb74f455ee'.
[root@server101 ~]# teamdctl TEAM1 state
setup:
  runner: activebackup
ports:
  eno33554960
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
  eno50332184
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
runner:
  active port: eno33554960

转载于:https://www.cnblogs.com/tdcqma/p/6040309.html

你可能感兴趣的:(配置链路聚合)