Configuring LACP on CentOS 7 Print

  • networking, lacp, bonding, linux, centos
  • 1

After completing the installation of CentOS 7, this guide can be used to configure the network interfaces with LACP.

 

Before getting started

It is recommended to run the steps in this guide as root.

Step 1 -  Find the interfaces to create the bond with

Run the ip link command to get an overview of the interfaces in the server, the output will help you find the interfaces which should be configured fort the bond.

[root@elias-demo ~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP mode DEFAULT group default qlen 1000
link/ether 38:ea:a7:14:be:6c brd ff:ff:ff:ff:ff:ff
3: eno2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
link/ether 38:ea:a7:14:be:6d brd ff:ff:ff:ff:ff:ff

The lo interface should be ignored, if after that only 2 interfaces remain, those interfaces need to be configured for the bond. If there are more interfaces you should look which should be configured, usually you can see this by looking at which interfaces have state UP, this means the interface is up.

Step 2 - Load the bonding module

The bonding module needs to be loaded to be able to create a bonded interface, in order to load this module, run: modprobe bonding.

Step 3 - Create the configuration for the bond

For CentOS7, the network configuration is stored in /etc/sysconfig/network-scripts/ifcfg-*, in this folder files can be created which will be used to configure the interfaces.

It is recommended to get started by changing directory to /etc/sysconfig/network-scripts/ (cd /etc/sysconfig/network-scripts/), after this, for the interfaces you want to configure the bond, delete the configuration files for the interfaces we are going to configure. (rm ifcfg-eno1, rm ifcf-eno2). 

Now we can re-create the configuration files on the server, you can do this by editing them (example: vi ifcfg-eno1)

put the following content in the file, replacing eno1 with the name of the interface:

TYPE=Ethernet
BOOTPROTO=none
DEVICE=eno1
ONBOOT=yes
MASTER=bond0
SLAVE=yes

Then create the configuration for the bond interface, you can do this by editing ifcfg-bond0, put the following content in this file:

DEVICE=bond0
TYPE=Bond
NAME=bond0
BONDING_MASTER=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.2.2
PREFIX=24
GATEWAY=192.168.2.1
DNS1=8.8.8.8
DNS2=9.9.9.9
BONDING_OPTS="mode=4 miimon=100 lacp_rate=1 xmit_hash_policy=1"

Example of the config folder after setting up the configuration:

[root@elias-test network-scripts]# ll
total 240
-rw-r--r--. 1 root root   207 Aug 11 15:17 ifcfg-bond0
-rw-r--r--. 1 root root    75 Aug 11 15:14 ifcfg-eno1
-rw-r--r--. 1 root root    75 Aug 11 15:15 ifcfg-eno2
[...TRUNCATED...]
[root@elias-test network-scripts]# cat ifcfg-eno1
TYPE=Ethernet
BOOTPROTO=none
DEVICE=eno1
ONBOOT=yes
MASTER=bond0
SLAVE=YES
[root@elias-test network-scripts]# cat ifcfg-eno2
TYPE=Ethernet
BOOTPROTO=none
DEVICE=eno2
ONBOOT=yes
MASTER=bond0
SLAVE=yes
[root@elias-test network-scripts]# cat ifcfg-bond0
DEVICE=bond0
TYPE=Bond
NAME=bond0
BONDING_MASTER=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.2.2
PREFIX=24
GATEWAY=192.168.2.1
DNS1=8.8.8.8
DNS2=9.9.9.9
BONDING_OPTS="mode=4 miimon=100 lacp_rate=1 xmit_hash_policy=1"

VI tips:

when entering the editor, press the a key to enter insert mode, where you can type and edit the file.
When you want to exit the editor, press: CTRL+C, then :wq and press enter.

Step 4  - Applying the configuration

In order to apply the configuration, you can run: service network restart, the files will be read and the configuration will be applied to the server. Another way to apply the configuration is by rebooting the server.


Was this answer helpful?

« Back