Linux网卡绑定实验

实验要求:在当前主机添加两块网卡,将两块网卡绑定实现网卡冗余操作

一、添加网卡

1、打开虚拟机设置,添加网络适配器

 2、通过查看ip a命令查看网卡是否添加成功

二、激活网卡

1、查看本地网卡情况

[root@localhost ~]# nmcli device 
DEVICE  TYPE      STATE                   CONNECTION         
ens160  ethernet  connected               ens160             
ens224  ethernet  connected               Wired connection 2 
ens256  ethernet  connected               Wired connection 1 
virbr0  bridge    connected (externally)  virbr0             
lo      loopback  unmanaged               --                 

2、激活网卡

[root@localhost ~]# nmcli device connect ens224
Device 'ens224' successfully activated with '86d51163-1571-3b91-974e-c2c8654e7b64'.
[root@localhost ~]# nmcli device connect ens256
Device 'ens256' successfully activated with '3fecf83b-5e95-3aea-98f0-6657af5c80ae'.

三、添加虚拟网卡team0

[root@localhost ~]# nmcli connection add type team con-name team0 ifname team0 config '{"runner": {"name": "activebackup"} }'
Connection 'team0' (b1c03e35-604a-4df9-8641-de1e75461910) successfully added.

四、虚拟绑定真实网卡

[root@localhost ~]# nmcli connection add type team-slave con-name team0-port1 ifname ens224 master team0
Connection 'team0-port1' (101ade9e-7721-4dfe-842e-4b53bc6a6d62) successfully added.
[root@localhost ~]# nmcli connection add type team-slave con-name team0-port2 ifname ens256 master team0
Connection 'team0-port2' (6d5d0e0f-e9cd-480a-9150-db3541d8fb22) successfully added.

五、激活设备

规则:先从后主

1、激活从设备

[root@localhost ~]# nmcli connection up team0-port1
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/14)
[root@localhost ~]# nmcli connection up team0-port2
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/15)

2、激活主设备

[root@localhost ~]# nmcli connection up team0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/16)

3、查看是否激活

 六、查看启动后的虚拟网卡team0的状态

 七、当停止其中一个设备后的状态

[root@localhost ~]# nmcli connection down team0-port1
Connection 'team0-port1' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/17)
[root@localhost ~]# nmcli device disconnect ens224
Error: Device 'ens224' (/org/freedesktop/NetworkManager/Devices/4) disconnecting failed: This device is not active
Error: not all devices disconnected.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值