CentOS 7 Teaming 和 Bridge

Posted by Sunday on 2018-07-23

teaming

为了提高网络容错或吞吐量,一般服务器都会采取多网卡绑定的策略,在RHEL6中使用的是Bonding,而RHEL7提供了一项新的实现技术Teaming.

使用teaming替换bonding实现链路聚合网卡绑定
team0:eth1 eth2

安装team

1
2
yum install -y teamd
modprobe team

查看所有网卡

1
2
3
4
5
6
nmcli con show

NAME UUID TYPE DEVICE
Wired connection 1 fe17083e-df87-3723-bdb9-010cf77fa1db ethernet eth1
Wired connection 2 175c3f7f-ab9a-31d2-b86d-03e64c383830 ethernet eth2
eth0 5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03 ethernet eth0

创建team0

1
nmcli connection add con-name team0 ifname team0 type team config '{"runner":{"name":"loadbalance"}}'

#主备命令nmcli connection modify team0 team.runner activebackup team.link-watchers “name=ethtool”

将eth1 eth2 加入team0中

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

配置静态ip

1
2
nmcli connection modify team0 ipv4.method manual ipv4.addresses 192.168.8.10/24  \
ipv4.gateway 192.168.8.2 ipv4.dns 192.168.8.2 ipv4.method manual

激活eth1 eth2 team0

1
2
3
nmcli connection up eth1
nmcli connection up eth2
nmcli connection up team0

查看team状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
teamdctl team0 state

setup:
runner: loadbalance
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

bridge

##删除teaming

1
2
3
4
nmcli con del eth1
nmcli con del eth2
nmcli con del team0
nmcli con show

配置bridge

1
2
3
4
nmcli con add con-name bridge0 type bridge ifname bridge0 ip4 192.168.8.10/24 gw4 192.168.8.2 
nmcli con mod bridge0 ipv4.method manual
nmcli con add con-name bridge0-slave1 type bridge-slave ifname eth1 master bridge0
nmcli con add con-name bridge0-slave2 type bridge-slave ifname eth2 master bridge0