Linux

产生team的虚拟网卡

[root@localhost /]# nmcli c add type team con-name team_conn ifname team_dev config '{"runner": {"name": "activebackup"}}' ipv4.addresses 192.168.72.129 ipv4.gateway 192.168.233.2 ipv4.dns 8.8.8.8 ipv4.method manual

连接 "team_conn" (e74ee3c6-a85e-435c-bca0-481cb4b31509) 已成功添加。

[root@localhost /]# ifconfig

ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.72.129  netmask 255.255.255.0  broadcast 192.168.72.255

        inet6 fe80::64ed:d66a:b65:8331  prefixlen 64  scopeid 0x20<link>

        ether 00:0c:29:47:e9:f5  txqueuelen 1000  (Ethernet)

        RX packets 51  bytes 9773 (9.5 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 53  bytes 6551 (6.3 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens224: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        ether 00:0c:29:47:e9:ff  txqueuelen 1000  (Ethernet)

        RX packets 7  bytes 637 (637.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 25  bytes 3230 (3.1 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        inet6 ::1  prefixlen 128  scopeid 0x10<host>

        loop  txqueuelen 1000  (Local Loopback)

        RX packets 1981  bytes 167546 (163.6 KiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 1981  bytes 167546 (163.6 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

team_dev: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500

        inet 192.168.72.129  netmask 255.255.255.255  broadcast 0.0.0.0

        inet6 fe80::cf00:2831:9b01:af57  prefixlen 64  scopeid 0x20<link>

        ether 00:0c:29:47:e9:ff  txqueuelen 1000  (Ethernet)

        RX packets 7  bytes 511 (511.0 B)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 25  bytes 3230 (3.1 KiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

将设备ens160断开,验证主备机制是否建立

[root@localhost /]# nmcli d disconnect ens160

成功断开设备 "ens160"。

[root@localhost /]# nmcli c modify team_conn config '{"runner": {"name": "activebackup", "hwaddr_policy": "by_active"}}'

[root@localhost /]# nmcli c up team_conn

连接已成功激活(master waiting for slaves)(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/79)

[root@localhost /]# nmcli c

NAME         UUID                                  TYPE      DEVICE   

team_conn    e74ee3c6-a85e-435c-bca0-481cb4b31509  team      team_dev

team_port2   68bcf374-3c96-43c5-9f0c-93a6c1849d62  ethernet  ens224   

ens160       2967af45-2aed-47ed-a74b-fac77a7c307f  ethernet  --       

rhce_auto    820a559a-a762-485b-9f31-ac1f884b9ef8  ethernet  --       

rhce_static  808b31aa-a433-459a-92f1-2d4e6b66dc0c  ethernet  --       

team_port1   5faf8a20-5fda-4379-9f58-d92b522f0a33  ethernet  --       

 

  1. 桥接

[root@localhost /]# nmcli c delete team_conn team_port2 team_port1

成功删除连接 "team_conn" (e74ee3c6-a85e-435c-bca0-481cb4b31509)。

成功删除连接 "team_port2" (68bcf374-3c96-43c5-9f0c-93a6c1849d62)。

成功删除连接 "team_port1" (5faf8a20-5fda-4379-9f58-d92b522f0a33)。

[root@localhost /]# nmcli c add type bridge con-name br1 ifname br1 ipv4.addresses 192.168.72.129/24 ipv4.gateway 192.168.233.2 ipv4.dns 8.8.8.8 ipv4.method manual

连接 "br1" (b4968bc8-925a-4924-9f92-fc6d8443577c) 已成功添加。

[root@localhost /]# nmcli c add type bridge-slave con-name br1_port1 ifname ens160 master br1

连接 "br1_port1" (8a36efbd-c5dc-461d-a0e3-72cbbf8ecefc) 已成功添加。

[root@localhost /]# nmcli c add type bridge-slave con-name br1_port2 ifname ens224 master br1

连接 "br1_port2" (22b0eac1-0acb-427a-94e8-bca6fc096843) 已成功添加。

[root@localhost /]# nmcli c up br1_port1

连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/83)

[root@localhost /]# nmcli c up br1_port2

连接已成功激活(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/84)

[root@localhost /]# nmcli c up br1

连接已成功激活(master waiting for slaves)(D-Bus 活动路径:/org/freedesktop/NetworkManager/ActiveConnection/85)

[root@localhost /]# tcpdump icmp -i ens160

验证:

 

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值