创建 bond 接口配置文件

  • systemctl status NetworkManager && systemctl start NetworkManage
  • nmcli con add type bond ifname bond0 mode active-backup
  • nmcli con add type bond-slave ifname enp2s0f0 master bond0
  • nmcli con add type bond-slave ifname enp2s0f1 master bond0

将原来的网卡配置文件备份并删除

  • cd /etc/sysconfig/network-scripts/
  • mkdir bk && mv ifcfg-enp2s0f* bk/

对 bond0 配置网络信息并启动网络进行测试

  • sed -i 's/dhcp/static/g' /etc/sysconfig/network-scripts/ifcfg-bond-bond0
  • echo "IPADDR=192.168.2.110" >> /etc/sysconfig/network-scripts/ifcfg-bond-bond0
  • echo "NETMASK=255.255.255.0" >> /etc/sysconfig/network-scripts/ifcfg-bond-bond0
  • echo "GATEWAY=192.168.2.1" >> /etc/sysconfig/network-scripts/ifcfg-bond-bond0
  • echo "DNS1=127.0.0.1" >> /etc/sysconfig/network-scripts/ifcfg-bond-bond0
  • nmcli con up bond-slave-enp2s0f0
  • nmcli con up bond-slave-enp2s0f1
  • nmcli con up bond-bond0
  • systemctl restart network
  • ip a | grep bond0
  • cat /proc/net/bonding/bond0
  • cat /sys/class/net/bond0/
说明:
   不支持对不使用网络交换机的直接线缆连接进行绑定操作。笔者做个测试,使用hub进行bonding测试,当断掉其中一个从属接口是是不会自动进行切换的,拔了网线(down)才可以。
   bond0 其实就是主接口、enp2s0f0,enp2s0f1 就是所谓的从属接口
   如果bond启动异常,可以尝试停止NetworkManager服务
   下面是官方的一些介绍,有意思的童鞋可以查阅下:

# Root Cause
- The Linux bonding driver is not developed or tested with crossover in mind, either by Red Hat or the upstream Linux community.
- Such a configuration is at odds with accepted industry recommendations for redundancy and reliability.
- The Bonding module in MII monitoring mode concerns itself with the state of the "link" as reported by the PHY'1 in the NIC, so with the state the hardware and the electrical signalling is reported.
- If an interface is administratively disabled in such a configuration, the `PHY` may still maintain electrical connectivity to the peer and failover will not work as expected, leading to a lack of bond communication.
- This is a hardware/PHY/firmware design point, and not something to be fixed in software. As this is very hardware dependant, it is best to simulate all failure scenarios prior deployment.
- Whilst the ARP monitoring mode could be used, there are few configurations where it would theoretically work, and it is easily possible to get such systems into a state where link appears up but communication does not work.

未完待续内容预告......

Centos7 使用 nmcli 命令行工具配置 bond 之章节二

  • fail_over_mac=0/1
  • miimon=time_in_milliseconds

    Centos7 配置 bond 的 VLAN 子接口之章节三

  • B3log

    B3log 是一个开源组织,名字来源于“Bulletin Board Blog”缩写,目标是将独立博客与论坛结合,形成一种新的网络社区体验,详细请看 B3log 构思。目前 B3log 已经开源了多款产品:PipeSoloSymWide 等,欢迎大家加入,贡献开源。

    2818 引用 • 4207 回帖 • 644 关注
  • CentOS

    CentOS(Community Enterprise Operating System)是 Linux 发行版之一,它是来自于 Red Hat Enterprise Linux 依照开放源代码规定释出的源代码所编译而成。由于出自同样的源代码,因此有些要求高度稳定的服务器以 CentOS 替代商业版的 Red Hat Enterprise Linux 使用。两者的不同在于 CentOS 并不包含封闭源代码软件。

    138 引用 • 131 回帖 • 692 关注
  • nmcli
    1 引用
感谢    关注    收藏    赞同    反对    举报    分享