1、介绍
nmcli是networkmanager提供的网络管理工具,nmcli设置的bond可以持久化,因为会写入配置文件,下面我们就来通过nmcli来配置bond聚合口。
2、配置步骤
【1】创建bond连接
[root@xxx ~]# nmcli conn add type bond con-name bond0 ifname bond0 ipv4.address 1.1.1.1/24 ipv4.method manual bond.options "mode=1,miimon=100" connection 'bond0' (cb2d7d4b-2ce8-41d8-b027-2d5b1032e237) successfully added.
可以发现/etc/sysconfig/network-scripts产生了一个ifcfg-bond0的配置文件:
[root@xxx network-scripts]# cat ifcfg-bond0 bonding_opts="mode=active-backup miimon=100" type=bond bonding_master=yes 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=bond0 uuid=cb2d7d4b-2ce8-41d8-b027-2d5b1032e237 device=bond0 onboot=yes ipaddr=1.1.1.1 prefix=24
【2】添加从属接口
[root@xxx network-scripts]# nmcli conn add type bond-slave con-name p112p1 ifname p112p1 master bond0 connection 'p112p1' (91fcfef7-6650-4184-a107-39ba4b695a0b) successfully added. [root@xxx network-scripts]# nmcli conn add type bond-slave con-name p112p2 ifname p112p2 master bond0 connection 'p112p2' (2cef6090-07b7-485f-b140-f553185ae994) successfully added.
查看产生的配置文件:
[root@xxx network-scripts]# cat ifcfg-p112p1 type=ethernet name=p112p1 uuid=91fcfef7-6650-4184-a107-39ba4b695a0b device=p112p1 onboot=yes master=bond0 slave=yes [root@xxx network-scripts]# cat ifcfg-p112p2 type=ethernet name=p112p2 uuid=2cef6090-07b7-485f-b140-f553185ae994 device=p112p2 onboot=yes master=bond0 slave=yes
【3】激活bond口
查看bond口和聚合口连接信息:
[root@xxx network-scripts]# nmcli conn show | grep -e 'bond0|p112p1|p112p2' bond0 cb2d7d4b-2ce8-41d8-b027-2d5b1032e237 bond -- p112p1 91fcfef7-6650-4184-a107-39ba4b695a0b ethernet -- p112p2 2cef6090-07b7-485f-b140-f553185ae994 ethernet --
激活接口,当连接名称重复时,建议用uuid去激活:
[root@xxx network-scripts]# nmcli conn up bond0 connection successfully activated (master waiting for slaves) (d-bus active path: /org/freedesktop/networkmanager/activeconnection/13) [root@xxx network-scripts]# nmcli conn up p112p1 connection successfully activated (d-bus active path: /org/freedesktop/networkmanager/activeconnection/16) [root@xxx network-scripts]# nmcli conn up p112p2 connection successfully activated (d-bus active path: /org/freedesktop/networkmanager/activeconnection/17)
查看bond信息:
[root@xxx network-scripts]# cat /proc/net/bonding/bond0 ethernet channel bonding driver: v3.7.1 (april 27, 2011) bonding mode: fault-tolerance (active-backup) primary slave: none currently active slave: p112p1 mii status: up mii polling interval (ms): 100 up delay (ms): 0 down delay (ms): 0 peer notification delay (ms): 0 slave interface: p112p1 mii status: up speed: 1000 mbps duplex: full link failure count: 0 permanent hw addr: 00:0d:48:4e:9f:e5 slave queue id: 0 slave interface: p112p2 mii status: up speed: 1000 mbps duplex: full link failure count: 0 permanent hw addr: 00:0d:48:4e:9f:e6 slave queue id: 0
总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。
发表评论