nmcli-3种网卡绑定方式

时间:2024-04-14 14:45:12

**

一、配置Teaming高可用

**
查看本地网卡情况:
[[email protected] ~]# nmcli device show
示例文件路径:
[[email protected] ~]# cd /usr/share/doc/teamd-1.17/example_configs/
[[email protected] example_configs]# ll
nmcli-3种网卡绑定方式
实验环境:
RHEL7.2,添加两个网卡,共三个网卡。将其中两个网卡进行绑定测试。

1.创建team0设备team0会话:
[[email protected] ~]# nmcli connection add type team con-name team0 ifname team0 config ‘{“runner”: {“name”: “activebackup”}}’
查看创建的team0会话:
[[email protected] ~]# nmcli connection show
2.添加网卡设备到team0中:
[[email protected] ~]# nmcli connection add type team-slave con-name team0-port1 ifname eno33554992 master team0
[[email protected] ~]# nmcli connection add type team-slave con-name team0-port2 ifname eno50332216 master team0
3.**从设备
[[email protected] ~]# nmcli connection up team0-port1
[[email protected] ~]# nmcli connection up team0-port2
4.**主设备:
[[email protected] ~]# nmcli connection up team0
查看**后team0的状态:
[[email protected] ~]# teamdctl team0 state
nmcli-3种网卡绑定方式
5.使用未绑定的网卡与team0进行ping测试:
(此处SSH远程连接的网卡为未绑定的网卡)
nmcli-3种网卡绑定方式
nmcli-3种网卡绑定方式
停用team0-port1设备后进行ping测试:
[[email protected] ~]# nmcli connection down team0-port1
[[email protected] ~]# teamdctl team0 state
nmcli-3种网卡绑定方式
nmcli-3种网卡绑定方式
停用team0-port2设备后进行ping测试:
[[email protected] ~]# nmcli connection up team0-port1
[[email protected] ~]# nmcli connection down team0-port2
[[email protected] ~]# teamdctl team0 state
nmcli-3种网卡绑定方式
nmcli-3种网卡绑定方式
将team0-port1与team0-port2同时停用并进行ping测试:
[[email protected] ~]# nmcli connection down team0-port1
[[email protected] ~]# teamdctl team0 state
nmcli-3种网卡绑定方式
nmcli-3种网卡绑定方式
(将两个从设备停用之后ping测试依旧正常的原因是应为未绑定的网卡与team0在同一网段,所以可以ping通。)
**

二、配置软件桥接

**
1.创建一个软件桥接设备和会话:
[[email protected] ~]# nmcli connection add type bridge con-name br1 ifname br1
2.添加从设备和会话到桥接设备
[[email protected] ~]# nmcli connection add type bridge-slave con-name br1-port1 ifname eno33554992 master br1
3.启动从设备会话:
[[email protected] ~]# nmcli connection up br1-port1
4.启动桥接会话:
[[email protected] ~]# nmcli connection up br1
配置软件桥接网卡的IP地址、网关及IP地址的获取方式:
[[email protected] ~]# nmcli connection modify br1 ipv4.addresses 192.168.199.210/24 ipv4.gateway 192.168.199.128 ipv4.method manual

三、配置桥接 team0

1:配置team0
配置方式同实验一。
配置完成后停用team0设备:
[[email protected] ~]# nmcli device disconnect team0
2:停用NetworkManager服务
[[email protected] ~]# systemctl stop NetworkManager
3:配置br0的配置文件
nmcli-3种网卡绑定方式
4.编辑team0的配置文件:
在配置文件的最后追加一下内容:

nmcli-3种网卡绑定方式
nmcli-3种网卡绑定方式
(team0里写的br0是主设备)
5.重启网络服务
[[email protected] ~]# systemctl restart NetworkManager
[[email protected] ~]# nmcli device connect team0
nmcli-3种网卡绑定方式
nmcli-3种网卡绑定方式