Wednesday 16 August 2017

How to Setup NIC bonding in RHEL7/Centos7



NIC Bonding enables two or more network interfaces to act as one interface, to provide higher data rates and as well as link failover. Linux kernel features that allows aggregating multiple interfaces. This is a great way of achieving redundancy to a server. If one physical NIC is down or unplugged, it will automatically move resource to other NIC card.
In Linux network configuration files stored in /etc/sysconfig/network-scripts/ directory.
Step-1: Create Configuration Files
We need to create these below files in /etc/sysconfig/network-scripts/ directory and append the below parameters on respective files:

[root@linuxcnf ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0
NAME=bond0
TYPE=Bond
BONDING_MASTER=yes
IPADDR=192.168.43.105
NETMASK=255.255.255.0
GATEWAY=192.168.43.1
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
NM_CONTROLLED=no
BONDING_OPTS="mode=1 miimon=100"

Here, you need to replace IP address as per actual setup IP addresses.
Similarly, Modify eth0 and eth1 interfaces configuration files and append the below parameters as below:

[root@linuxcnf ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
TYPE=Ethernet
USERCTL=no
ONBOOT=yes
BOOTPROTO=none
NM_CONTROLLED=no
MASTER=bond0
SLAVE=yes

[root@linuxcnf ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE=eth1
TYPE=Ethernet
USERCTL=no
ONBOOT=yes
BOOTPROTO=none
NM_CONTROLLED=no
MASTER=bond0
SLAVE=yes

Step-2: Load bond driver/module
Check bonding driver/module is loaded for NIC-bonding interface (bond0) is bringing up.
First, load the bonding module, enter:

[root@linuxcnf ~]# modprobe bond
Step-3: Restarting Network service:
Now we can restart the network service in order to bring up bond0 interface:

[root@linuxcnf ~]# service network restart

Step-4:  Verify Bond Configuration:
Enter the below commands to verify the bonding configuration status from Linux kernel bonding driver:

[root@linuxcnf ~]# 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: eth0
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
Slave Interface: eth0
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 14:f6:34:23:fd:1a
Slave queue ID: 0
Slave Interface: eth1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 14:f6:34:32:fd:1b
Slave queue ID: 0

[root@linuxcnf ~]# ifconfig
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.43.105  netmask 255.255.255.0  broadcast 192.168.43.1
        inet6 df80::32e1:71df:fe54:df0a  prefixlen 64  scopeid 0x20<link>
        ether 14:f6:34:23:fd:1a txqueuelen 1000  (Ethernet)
        RX packets 6231499  bytes 3275041689 (3.0 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1994973  bytes 485209953 (462.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
eth0: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 14:f6:34:23:fd:1a txqueuelen 1000  (Ethernet)
        RX packets 1293869  bytes 113523260 (108.2 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 16
eth1: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 14:f6:34:32:fd:1b txqueuelen 1000  (Ethernet)
        RX packets 4937630  bytes 3161518429 (2.9 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1994973  bytes 485209953 (462.7 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 17
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 4276  bytes 264988 (258.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4276  bytes 264988 (258.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Bond configuration done!!!

No comments:

Post a Comment