centos7绑定双网卡

Centos7绑定双网卡:

#安装必需的包:

1
yum install  teamd  -y

#停止NetworkManager

1
2
3
systemctl   stop  NetworkManager

systemctl disable NetworkManager

#Creating a Network Team Using ifcfg Files

1
2
3
4
5
6
7
8
9
10
11
12
13
cd /etc/sysconfig/network-scripts/

vi ifcfg-team0

DEVICE=team0
DEVICETYPE=Team
ONBOOT=yes
BOOTPROTO=none
IPADDR=192.168.10.110
PREFIX=24
GATEWAY=192.168.10.254
TEAM_CONFIG='{"runner": {"name": "activebackup"}, "link_watch": {"name": "ethtool"}}'

1
2
3
4
5
6
7
# cat ifcfg-eno1
DEVICETYPE=TeamPort
TEAM_MASTER=team0
TEAM_PORT_CONFIG='{"prio":100}'
NAME=eno1
DEVICE=eno1
ONBOOT=yes
1
2
3
4
5
6
7
8
# cat ifcfg-eno2

DEVICETYPE=TeamPort
TEAM_MASTER=team0
TEAM_PORT_CONFIG='{"prio":99}'
NAME=eno2
DEVICE=eno2
ONBOOT=yes
1
2
3
#重启网络

systemctl restart network

#检查端口状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
teamnl team0 ports



1: eth0: up 1000Mbit FD

2: eth1: up 1000Mbit FD



#检查teaming状态

teamdctl team0 state



setup:

runner: activebackup

ports:

eno1

link watches:

link summary: up

instance[link_watch_0]:

name: ethtool

link: up

eno2

link watches:

link summary: up

instance[link_watch_0]:

name: ethtool

link: up

runner:

active port: eno1





#手动断开其中一条链路验证主备模式切换是否正常

ip link set eno1 down



teamdctl team0 state



setup:

runner: activebackup

ports:

eno1

link watches:

link summary: up

instance[link_watch_0]:

name: ethtool

link: up

eno2

link watches:

link summary: up

instance[link_watch_0]:

name: ethtool

link: up

runner:

active port: eno2