How to setup LACP network bonding interface on RHEL / CentOS 7
After setting up port channeling at a enclosure switch, on a port for a new machine, i had to create a bonded network interface with LACP, to get the port channel to work.
I determined that it did not work, that the port channel was not "Up", by running # show interfaces status
(a DELL switch):
enclxx-sw-a#show interfaces status
..
Po1 Server: hostname01 Down
..
This was, of course, because the network interface was not bonded. I started out creating a new file in the /etc/modprobe.d/ directory (loadable kernel module directory), called bonding.conf (# vi /etc/modprobe.d/bonding.conf
):
alias bond0 bonding
options bond0 miimon=100 mode=4 lacp_rate=1
Here you define the bond0 network interface as a bonding interface. You can set bonding options here, or in the ifcfg-bond0 network-script itself. I like to keep it together in the bonding.conf-file.
About mode 4 (kernel.org):
IEEE 802.3ad Dynamic link aggregation. Creates
aggregation groups that share the same speed and
duplex settings. Utilizes all slaves in the active
aggregator according to the 802.3ad specification.
Now we have to create the network-scripts. We have to create the following files, one by one:
/etc/sysconfig/network-scripts/ifcfg-em1
/etc/sysconfig/network-scripts/ifcfg-em2
/etc/sysconfig/network-scripts/ifcfg-bond0
em1 and em2 as slaves, and bond0 as a master to bond these:
Use your prefered editor (i like vim) to edit these files, defining network properties for your interfaces:
/etc/sysconfig/network-scripts/ifcfg-em1
# vi /etc/sysconfig/network-scripts/ifcfg-em1
BOOTPROTO=none
NM_CONTROLLED=no
NAME=em1
DEVICE=em1
ONBOOT=yes
MASTER=bond0
SLAVE=yes
/etc/sysconfig/network-scripts/ifcfg-em2
# vi /etc/sysconfig/network-scripts/ifcfg-em2
BOOTPROTO=none
NM_CONTROLLED=no
NAME=em2
DEVICE=em2
ONBOOT=yes
MASTER=bond0
SLAVE=yes
/etc/sysconfig/network-scripts/ifcfg-bond0
# vi /etc/sysconfig/network-scripts/ifcfg-bond0
IPADDR=10.100.0.10
NETMASK=255.255.255.0
BROADCAST=10.100.0.255
NETWORK=10.100.0.0
GATEWAY=10.100.0.254
NAME=bond0
DEVICE=bond0
USERCTL=no
ONBOOT=yes
Go on and restart your network:
# systemctl restart network.service
If this does not work, go and do the status command, to examine further:
# systemctl status network.service
You may have to reboot to reload the network cards, and make the OS understand that it has been bonded:
# reboot
Before rebooting you may have to delete the 70-persistent-net.rules-file, to make the interfaces and network cards work probably, resetting these information:
# rm -f /etc/udev/rules.d/70-persistent-net.rules
After booting, check if everything seems OK, with # ip addr
, or iconfig
.
Check the status of your bonding interface with the /proc/net/bonding/bond0-file:
# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer2 (0)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
802.3ad info
LACP rate: fast
Min links: 0
Aggregator selection policy (ad_select): stable
Active Aggregator Info:
Aggregator ID: 1
Number of ports: 2
Actor Key: 17
Partner Key: 146
Partner Mac Address: f8:b1:56:65:30:0b
Slave Interface: em1
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 90:b1:1c:ed:47:81
Aggregator ID: 1
Slave queue ID: 0
Slave Interface: em2
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 90:b1:1c:ed:47:83
Aggregator ID: 1
Slave queue ID: 0
Check your switch/network-devices aswell:
enclxx-sw-a#show interfaces status
..
Po1 Server: hostname01 Up
..
Everything was up and running. I could even ping Google's DNS server (8.8.8.8).
Comment here if you got any problems.