bonding广播模式
#创建测试环境
bash
# 创建网络命名空间
ip netns add bond-ns1
ip netns add bond-ns2
# 创建三对 veth 接口(使用三对以演示主备模式)
ip link add veth0-ns2 type veth peer name veth0-ns1
ip link add veth1-ns2 type veth peer name veth1-ns1
# 将 veth-ns 端移到命名空/
ip link set veth0-ns1 netns bond-ns1
ip link set veth1-ns1 netns bond-ns1
ip link set veth0-ns2 netns bond-ns2
ip link set veth1-ns2 netns bond-ns2
# 创建 bond1 接口
#ip netns exec bond-ns1 ip link add bond1 type bond mode 3 miimon 100
ip netns exec bond-ns1 ip link add bond1 type bond mode 3
# 将 veth 接口添加到 bond
ip netns exec bond-ns1 ip link set veth0-ns1 master bond1
ip netns exec bond-ns1 ip link set veth1-ns1 master bond1
# 激活所有接口
ip netns exec bond-ns1 ip link set veth0-ns1 up
ip netns exec bond-ns1 ip link set veth1-ns1 up
ip netns exec bond-ns1 ip link set bond1 up
ip netns exec bond-ns1 ip link set lo up
# 为 bond1 分配 IP 地址
ip netns exec bond-ns1 ip addr add 192.168.10.1/24 dev bond1
#检查 bond0 状态(在命名空间)
ip netns exec bond-ns1 cat /proc/net/bonding/bond1
# 创建 bond2 接口
#ip netns exec bond-ns2 ip link add bond2 type bond mode 3 miimon 100
ip netns exec bond-ns2 ip link add bond2 type bond mode 3
# 将 veth 接口添加到 bond
ip netns exec bond-ns2 ip link set veth0-ns2 master bond2
ip netns exec bond-ns2 ip link set veth1-ns2 master bond2
# 激活所有接口
ip netns exec bond-ns2 ip link set veth0-ns2 up
ip netns exec bond-ns2 ip link set veth1-ns2 up
ip netns exec bond-ns2 ip link set bond2 up
ip netns exec bond-ns2 ip link set lo up
# 为 bond2 分配 IP 地址
ip netns exec bond-ns2 ip addr add 192.168.10.2/24 dev bond2
#检查 bond0 状态(在命名空间)
ip netns exec bond-ns2 cat /proc/net/bonding/bond2
