NIC Teaming

最後更新: 2023-03-23

目錄

  • Install & Config
  • Runners
  • activebackup mode
  • link-watchers
  • Dump / Load config

 


Install & Config

 

# Rocky 8

dnf install teamd -y

# 查看有什麼 NIC (eth1, eth2)

nmcli con show

nmcli con add type team con-name team0 ifname team0
nmcli con add type team-slave ifname eth1 master team0
nmcli con add type team-slave ifname eth2 master team0

P.S.

nmcli con mod team-slave-eth1 master team0

nmcli con show

NAME             UUID                                  TYPE      DEVICE
System eth0      75cc1dc0-835c-4ecb-8799-9e770e9a975f  ethernet  eth0
team0            80095ad7-8c34-450c-83d0-31c71a22ed4b  team      team0
team-slave-eth1  b9d337a5-5d55-4ae5-8b88-2c429c3002a5  ethernet  eth1
team-slave-eth2  013b7e1e-8a8e-4d82-a595-6dc35f49c068  ethernet  eth2

 * team-slave-eth1 要 conn Up 後才有 DEVICE, 否則 DEVICE 是漏空的.

 * After bringing a port up the team should become active

 * Starting the network team interface does not automatically start the port interfaces.

nmcli con up team-slave-eth1
nmcli con up team-slave-eth2

P.S.

# 查看 conn 的 Device

nmcli con show team-slave-eth2 | grep connection.interface-name

# 查看 up / down

nmcli device

nmcli con mod team0 ipv4.method manual
nmcli con mod team0 ipv4.addresses '192.168.88.129/24'
nmcli con mod team0 ipv4.gateway '192.168.88.1'
nmcli con show team0 ipv6.method disabled

# Config File

/etc/sysconfig/network-scripts/ifcfg-team0

ONBOOT=yes
BOOTPROTO=none
DEVICE=team0
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=team0
DEVICETYPE=Team
IPADDR=192.168.88.129
PREFIX=24
GATEWAY=192.168.88.1
IPV6INIT=no
IPV6_DISABLED=yes

/etc/sysconfig/network-scripts/ifcfg-team-slave-eth1

DEVICE=eth1
ONBOOT=yes
NAME=team-slave-eth1
TEAM_MASTER=team0
DEVICETYPE=TeamPort

# JSON Config Example

ls -R /usr/share/doc/teamd/example_*

 


Runners

 

Runners are units of code which are compiled into the Team daemon
  when an instance of the daemon is created.

它可以理解成 mode

runners: broadcast | round-robin(DEFAULT) | active-backup | loadbalance | lacp

Runner config in the JSON format configuration

 


teamnl

 

teamnl - team network device Netlink interface tool

teamdctl - team daemon control tool

teamnl Usage:

teamnl teamdevname command [command args]

# By default team is using the roundrobin runner

teamdctl team0 state [-v]

setup:
  runner: roundrobin
ports:
  eth1
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
  eth2
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0

# list all currently available options

teamnl team0 options

# list port in team

teamnl team0 ports

 4: eth2: up 4294967295Mbit FD
 3: eth1: up 4294967295Mbit FD

# Add / Remove a Port to a Network Team

teamdctl team0 port add em1

teamdctl team0 port remove em1

 


activebackup mode

 

# 轉成 activebackup mode

nmcli con mod team0 team.runner activebackup

# Apply Settings

nmcli connection up team0

# 轉 active port

teamnl team0 ports

 4: eth2: up 4294967295Mbit FD
 3: eth1: up 4294967295Mbit FD

teamnl team0 getoption activeport

3

teamnl team0 setoption activeport 4

 


link-watchers

 

Link-state Monitoring

link-watchers: ethtool(Default) | arp_ping

# runner being delay notified about it. unit: milliseconds

"link_watch": {
       "name": "ethtool",
       "delay_up": 2500,
       "delay_down": 1000
}

 * when using the lacp runner, ethtool is the only recommended link-watcher

sticky & prio

   "ports": {
      "em1": {
         "prio": 20,
      },
      "em2": {
         "prio": 10,
         "sticky": true
      }
   }

ARP Ping

# interval: milliseconds

    "link_watch":{
        "name": "arp_ping",
        "interval": 100,
        "missed_max": 30,
        "source_host": "192.168.23.2",
        "target_host": "192.168.23.1"
    }

Example

cat MyConfig.json

{
  "runner": {
    "name": "activebackup"
  },
  "link_watch": {
    "name": "ethtool"
  },
  "ports": {
    "eth1": {
      "prio": 1,
      "sticky": true
    },
    "eth2": {
      "prio": 10
    }
  }
}

nmcli con mod team0 team.config MyConfig.json

nmcli connection up team0

 


VM 測試

 

virsh domiflist rocky8

 Interface   Type     Source   Model    MAC
-----------------------------------------------------------
 r8          bridge   vmbr0    virtio   88:88:88:88:88:25
 r8a         bridge   vmbr0    virtio   88:88:88:88:82:43
 r8b         bridge   vmbr0    virtio   88:88:88:88:82:44

virsh domif-setlink rocky8 r8a down

 


Dump / Load config

 

# Dump of team device configuration

teamdctl team0 config dump

{
 "device": "team0",
 "runner": {"name": "broadcast"},
 "ports": {"em1": {}, "em2": {}}
}

# Dump of nic of team

teamdctl team0 port config dump eth1

{
    "prio": 1,
    "sticky": true
}

# Load config

nmcli con mod team0 team.config 'JSON'

 

 

Creative Commons license icon Creative Commons license icon