Centos7 双网卡绑定及虚拟网卡设置


系统信息


#cat /etc/centos-release
CentOS Linux release 7.8.2003 (Core)
#uname -r
3.10.0-1127.el7.x86_64

双网卡team 绑定

这里采用 team 方式,类型为:roundrobin

nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name": "roundrobin"}}'  
nmcli con modify team0 ipv4.address '192.168.100.100/24' ipv4.gateway '192.168.100.2'
nmcli con modify team0 ipv4.method manual
nmcli con add type team-slave con-name team0-port1 ifname eth0 master team0
nmcli con add type team-slave con-name team0-port2 ifname eth1 master team0
nmcli con up team0-port1 
nmcli con up team0-port2

查看 team0 状态:

#teamdctl team0 st
setup:
  runner: roundrobin
ports:
  eth0
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
  eth1
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0

如果是物理机,可以尝试拔网线进行测试。这里不再演示。


team0 桥接设置

#cd /etc/sysconfig/network-scripts/
** 拷贝文件直接修改为 br0 配置文件 **
#cp -a ifcfg-team0 ifcfg-br0

#vim ifcfg-team0

TEAM_CONFIG="{\"runner\":{\"name\":\"roundrobin\"}}"
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=team0
UUID=9babcb45-31a0-4ed5-a657-b50b8676938e
DEVICE=team0
ONBOOT=yes
DEVICETYPE=Team
### 注释ip设置 ###
#IPADDR=192.168.1.100
#PREFIX=24
#GATEWAY=192.168.1.1
### 添加桥接 br0 ###
BRIDGE=br0 

** 修改 ifcfg-br0 文件 **
#cat ifcfg-br0
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
NAME=br0
DEVICE=br0
ONBOOT=yes
TYPE=bridge
IPADDR=192.168.1.100
PREFIX=24
GATEWAY=192.168.1.1
DNS1=223.5.5.5
DNS2=114.114.114.114
*****


** 重启网络 **
#systemctl restart network


** 查看桥接 **
#brctl show
bridge name	bridge id		STP enabled	interfaces
br0		8000.ac1f6bed99b2	yes		team0

** 绑定状态 **
#teamdctl team0 st
setup:
  runner: roundrobin
ports:
  eth0
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
  eth1
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0

本次双网卡绑定及设置虚拟网桥完成。


--- EOF ---
posted @ 2022-04-01 11:54  hukey  阅读(832)  评论(0编辑  收藏  举报