FoxuTech

How to Setup Network bonding in Linux

How to Setup Network bonding

The Linux bonding driver provides a method for aggregating multiple network interfaces into a single logical “bonded” interface. The behavior of the bonded interfaces depends upon the mode; generally speaking, modes provide either hot standby or load balancing services. Additionally, link integrity monitoring may be performed.

Read more: Basic Linux Networking Command

Create a bond0 configuration file

Red Hat Linux stores network configuration in /etc/sysconfig/network-scripts/ directory. First, you need to create bond0 config file:

# vi /etc/sysconfig/network-scripts/ifcfg-bond0
Append following lines to it:
 DEVICE=bond0
 IPADDR=192.168.0.14
 NETWORK=192.168.0.3
 NETMASK=255.255.255.0
 USERCTL=no
 BOOTPROTO=none
 ONBOOT=yes

Make sure you are replacing above IP address with your server/system IP address.

Modify eth0 and eth1 inferface config files:

Open both configuration using vi text editor and make sure file read as follows for eth0 interface

# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Modify/append directive as follows:
 DEVICE=eth0
 USERCTL=no
 ONBOOT=yes
 MASTER=bond0
 SLAVE=yes
 BOOTPROTO=none

Next open eth1 configuration file using your favorite editor:

# vi /etc/sysconfig/network-scripts/ifcfg-eth1
Change the file with your bond detail like below;
 DEVICE=eth1
 USERCTL=no
 ONBOOT=yes
 MASTER=bond0
 SLAVE=yes
 BOOTPROTO=none

Load bond driver/module

Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up. You need to modify kernel modules configuration file: (Append following two lines). Refer other Modes of Bonding End of the Document.

# vi /etc/modprobe.conf
 alias bond0 bonding
 options bond0 mode=balance-alb miimon=100

Test configuration

First, load the bonding module:

# modprobe bonding

Restart networking service in order to bring up bond0 interface:

# service network restart

Verify everything is working:

# less /proc/net/bonding/bond0

Bonding Mode: load balancing (round-robin)
MII Status: up
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth0
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:50:56:BC:FE:AE

Slave Interface: eth1
MII Status: up
Link Failure Count: 0
Permanent HW addr: 00:50:56:BC:FE:AE

List all interfaces:

# ifconfig
 bond0  Link encap:Ethernet  HWaddr 00:50:56:BC:FE:AE
 inet addr:192.168.0.161  Bcast:192.168.0.255  Mask:255.255.255.0
 inet6 addr: fe80::200:ff:fe00:0/64 Scope:Link
 UP BROADCAST RUNNING MASTER MULTICAST  MTU:1500  Metric:1
 RX packets:2804 errors:0 dropped:0 overruns:0 frame:0
 TX packets:1879 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:0

 eth0  Link encap:Ethernet  HWaddr 00:50:56:BC:FE:AE
 inet addr:192.168.0.161  Bcast:192.168.0.255  Mask:255.255.255.0
 inet6 addr: fe80::183e:6aff:feac:a001/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
 RX packets:2809 errors:0 dropped:0 overruns:0 frame:0
 TX packets:1390 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000

 eth1  Link encap:Ethernet  HWaddr 00:50:56:BC:FE:AE
 inet addr:192.168.0.161  Bcast:192.168.0.255  Mask:255.255.255.0
 inet6 addr: fe80::250:56ff:febc:feae/64 Scope:Link
 UP BROADCAST RUNNING SLAVE MULTICAST  MTU:1500  Metric:1
 RX packets:4 errors:0 dropped:0 overruns:0 frame:0
 TX packets:502 errors:0 dropped:0 overruns:0 carrier:0
 collisions:0 txqueuelen:1000

Modes of bonding :

RHEL bonding supports 7 possible “modes” for bonded interfaces. These modes determine the way in which traffic sent out of the bonded interface is actually dispersed over the real interfaces. Modes 0, 1, and 2 are by far the most commonly used among them.

Exit mobile version