Skip to content

Instantly share code, notes, and snippets.

@JeremyVV
Last active January 24, 2020 22:42
Show Gist options
  • Select an option

  • Save JeremyVV/2d6688ad88bef766bb0b8ddd791fd9f1 to your computer and use it in GitHub Desktop.

Select an option

Save JeremyVV/2d6688ad88bef766bb0b8ddd791fd9f1 to your computer and use it in GitHub Desktop.
[How To Create a Network Bond on RHEL 6] #rhel6 #bond #nicbond #networking
# #bond vars
# nmcli_bond:
# - conn_name: tenant
# ip4: '{{ tenant_ip }}'
# gw4: ''
# mode: balance-rr
# - conn_name: external
# ip4: '{{ external_ip }}'
# gw4: ''
# mode: balance-rr
# - conn_name: storage
# ip4: '{{ storage_ip }}'
# gw4: '{{ storage_gw }}'
# mode: balance-rr
# nmcli_bond_slave:
# - conn_name: em1
# ifname: em1
# master: tenant
# - conn_name: em2
# ifname: em2
# master: tenant
# - conn_name: p2p1
# ifname: p2p1
# master: storage
# - conn_name: p2p2
# ifname: p2p2
# master: external
#
# #ethernet vars
# nmcli_ethernet:
# - conn_name: em1
# ifname: em1
# ip4: '{{ tenant_ip }}'
# gw4: '{{ tenant_gw }}'
# - conn_name: em2
# ifname: em2
# ip4: '{{ tenant_ip1 }}'
# gw4: '{{ tenant_gw }}'
# - conn_name: p2p1
# ifname: p2p1
# ip4: '{{ storage_ip }}'
# gw4: '{{ storage_gw }}'
# - conn_name: p2p2
# ifname: p2p2
# ip4: '{{ external_ip }}'
# gw4: '{{ external_gw }}'
# ```
#
# ### host_vars
# ```yml
# ---
# storage_ip: "192.0.2.91/23"
# external_ip: "198.51.100.23/21"
# tenant_ip: "203.0.113.77/23"
# ```
- name: Try nmcli add bond - conn_name only & ip4 gw4 mode
nmcli:
type: bond
conn_name: '{{ item.conn_name }}'
ip4: '{{ item.ip4 }}'
gw4: '{{ item.gw4 }}'
mode: '{{ item.mode }}'
state: present
with_items:
- '{{ nmcli_bond }}'
- name: Try nmcli add bond-slave
nmcli:
type: bond-slave
conn_name: '{{ item.conn_name }}'
ifname: '{{ item.ifname }}'
master: '{{ item.master }}'
state: present
with_items:
- '{{ nmcli_bond_slave }}'

Table of Contents

Overview

In essense Network Bonding is network level redudancy so that in the event that a nic or swtich dies or that a network cable comes losse or is accidentally removed another nic will step in its pace immediately. Once you have configured the bonding with the help of two NIC cards, then any failure occurs on any one of the NIC cards the kernel will automatically detect the failed of NIC and act to remove it from the bond until it is fixed. Bonding could be also used for the load sharing between the two physical Links.

In this tutorial we will configure network bonding on RHEL 6 with two nics - eth0 & eth1 - to create a bond interface called bond0.

Check if Bonding Kernel Module is Installed

By default the bonding kernel module is not loaded. Failure to load the module may result in your system not enabling the nic bond.

modprobe --first-time bonding

No visual output indicates the module was not running and has now been loaded. This activation will not persist across system restarts.

More info about the bonding module can be obtained by running the following:

modinfo bonding

This can be helpful to determine which features are supported.

Create the Channel Bonding Interface

vi /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0
TYPE=Bond
ONBOOT=yes
BOOTPROTO=static
IPADDR=10.193.0.100
NETMASK=255.255.254.0
GATEWAY=10.193.0.1
USERCTL=no
NM_CONTROLLED=no
BONDING_OPTS="mode=1 miimon=100 updelay=60000 downdelay=0"

Different Modes options are:

  • 0 or balance-rr — round-robin mode for fault tolerance and load balancing.
  • 1 or active-backup — Sets active-backup mode for fault tolerance.
  • 2 or balance-xor — Sets an XOR (exclusive-or) mode for fault tolerance and load balancing.
  • 3 or broadcast — Sets a broadcast mode for fault tolerance. All transmissions are sent on all slave interfaces.
  • 4 or 802.3ad — Sets an IEEE 802.3ad dynamic link aggregation mode. Creates aggregation groups that share the same speed & duplex settings.
  • 5 or 5 — Sets a Transmit Load Balancing (TLB) mode for fault tolerance & load balancing.
  • 6 or balance-alb — Sets an Active Load Balancing (ALB) mode for fault tolerance & load balancing.

Media monitoring (miimon) can detect and respond to a failure of either the NIC or the switch it is directly connected to. This approach is robust and simple to configure but cannot detect failures beyond the directly connected switch.

Configure Eth0 for Bond0

vi /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
NM_CONTROLLED=no
HWADDR=08:00:27:5C:A8:8F
HOTPLUG=no

Configure Eth0 for Bond1

vi /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
NM_CONTROLLED=no
HWADDR=08:00:27:5C:A8:8E
HOTPLUG=no

Configure the Bonding Kernel Module

vi /etc/modeprobe.d/bonding.conf

alias bond0 bonding

Restart the Network

service network restart

Verify Bonding is Working

cat /proc/net/bonding/bond0

Helpful Links

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment