centos7.2的双网卡怎么绑定

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7.2的双网卡怎么绑定相关的知识,希望对你有一定的参考价值。

参考技术A centos7.2的双网卡用team实现网卡聚合链路脚本:

[plain] view plain copy
#!/bin/bash
#创建一个名为team0的链路接口
IP=192.168.101.1
GATE=192.168.101.254
ETH1=eno1
ETH2=eno2
#ETH3=eno3
#ETH4=eno4
nmcli con add type team con-name team0 ifname team0 config '"runner": "name":"activebackup"'
#nmcli con add type team con-name team1 ifname team1 config '"runner": "name":"activebackup"'
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-$ETH1
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=$ETH1
DEVICE=$ETH1
ONBOOT=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
PEERDNS=yes
PEERROUTES=yes
EOF
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-$ETH2
TYPE=Ethernet
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=$ETH2
DEVICE=$ETH2
ONBOOT=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
PEERDNS=yes
PEERROUTES=yes
EOF
cat <<EOF> /etc/sysconfig/network-scripts/ifcfg-team0
DEVICE=team0
TEAM_CONFIG="\"runner\": \"name\":\"activebackup\""
DEVICETYPE=Team
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=yes
IPV6INIT=no
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=team0
ONBOOT=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPADDR=$IP
PREFIX=24
GATEWAY=$GATE
EOF
nmcli connection add type team-slave con-name team0-port1 ifname $ETH1 master team0
nmcli connection add type team-slave con-name team0-port2 ifname $ETH2 master team0
nmcli connection up team0-port2
nmcli connection up team0-port1
reboot

验证:
1.查看team0状态:

[html] view plain copy
[root@localhost ~]# teamdctl team0 state view
setup:
runner: activebackup
ports:
eno1
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
eno2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eno1 #当前主接口

2.列出team0端口

[html] view plain copy
[root@localhost ~]# teamnl team0 ports
3: eno2: up 1000Mbit FD
2: eno1: up 1000Mbit FD

3.测试,宕掉当前主接口,看是否切换

[plain] view plain copy
[root@localhost ~]# nmcli device disconnect eno1
Device 'eno1' successfully disconnected.
[root@localhost ~]# teamnl team0 ports
3: eno2: up 1000Mbit FD
[root@localhost ~]# teamdctl team0 state view
setup:
runner: activebackup
ports:
eno2
link watches:
link summary: up
instance[link_watch_0]:
name: ethtool
link: up
down count: 0
runner:
active port: eno2 #切换成功

以上是关于centos7.2的双网卡怎么绑定的主要内容,如果未能解决你的问题,请参考以下文章

centos7.2网卡绑定

Centos7双网卡绑定

Centos7 / RHEL 7 双网卡绑定

Centos上的双网卡绑定

记录一次centos的双网卡绑定

centos7.2下无线网卡安装问题,求助