This article shows what files to add if you want to add a bonding interface under CentOS 8 without invoking the Network manager command utility.
Our goal is to use one boding group with the name bond0 in LACP (aka 802.3ad) mode (but it could be any of the other types) with two networks 10Gbps interfaces. The setup resented here uses NetworkManager, which handles the loading of bonding module properly.
In fact, the network-scripts are now deprecated and they are missing from the system (but they still exist in the additional package – “network-scripts”, who knows till when? do not rely on them!).
The configuration files are with the same syntax as under CentOS 7, but this time the network manager parses them. The ifup and ifdown still exist and they just call the Network manager when executed (unless the “network-scripts” package is installed). If you need to enable bonding without any configuration files (for emergency situations) you may still use – How to enable Linux bonding without ifenslave
What do you need:
- Ensure you have installed: “iputils” and “NetworkManager” packages
dnf install -y NetworkManager iputils
- Ensure the NetworkManager service is running
systemctl enable NetworkManager systemctl start NetworkManager
STEP 1) Configure the bonding device
The boding interface’s name will be bond0 and the configuration will be located in /etc/sysconfig/network-scripts/ifcfg-bond0
BONDING_OPTS="mode=4 miimon=100" TYPE=Bond BONDING_MASTER=yes BOOTPROTO=none IPADDR0=192.168.0.100 PREFIX0=24 GATEWAY0=192.168.0.1 DNS1=126.96.36.199 DNS2=188.8.131.52 IPV4_FAILURE_FATAL=no NAME=bond0 UUID=e19e2059-2e31-4143-915a-cdc11d19c9d6 DEVICE=bond0 ONBOOT=yes
As you can see we use IPADDR0, PREFIX0 and GATEWAY0, because it is easy to add multiple IPs (and gateways) with suffix 1,2,…N (just add IPADDR1,PREFIX1 and if any GATEWAY1). Add the default gateway for the system in /etc/sysconfig/network
STEP 2) Configuring the network cards
Using two network cards in our bodning group we have two configuration files for each of the network interaces:
The configuration file for the first network interface ens1f0 (in your case may be with another name) is /etc/sysconfig/network-scripts/ifcfg-ens1f0:
TYPE=Ethernet BOOTPROTO=none NAME=ens1f0 UUID=0e747c1a-3ad6-40ef-b7d7-8358ec5f11f9 DEVICE=ens1f0 ONBOOT=yes MASTER=bond0 SLAVE=yes
And only change the name of the second network card in the configuration file with name /etc/sysconfig/network-scripts/ifcfg-ens1f1:
TYPE=Ethernet BOOTPROTO=none NAME=ens1f1 UUID=c5900e93-32a0-4f58-afd6-64e09f5238a8 DEVICE=ens1f1 ONBOOT=yes MASTER=bond0 SLAVE=yes
Of course, the UUID file should be different in all configuration files (aka devices).
STEP 3) Start the bonding network interface
Start the inteface with ifup
[root@srv ~]# ifup bond0 Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/4)
No error and output for successful activation – now your machine may use the bond0 network interface.
The above command will start only the bonding interface, but you may want to restart the whole network:
systemctl restart NetworkManager
Or only reloading the NetworkManager configurations
nmcli connection reload
And the boding is UP and RUNNING:
[root@srv ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether ac:1f:6b:00:77:6e brd ff:ff:ff:ff:ff:ff 3: eno2: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000 link/ether ac:1f:6b:00:77:6f brd ff:ff:ff:ff:ff:ff 4: ens1f0: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000 link/ether 00:1b:21:cc:32:ef brd ff:ff:ff:ff:ff:ff 5: ens1f1: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc mq master bond0 state UP group default qlen 1000 link/ether 00:1b:21:cc:32:ef brd ff:ff:ff:ff:ff:ff 6: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:1b:21:cc:32:ef brd ff:ff:ff:ff:ff:ff inet 192.168.0.100/24 brd 192.168.0.1 scope global noprefixroute bond0 valid_lft forever preferred_lft forever
If you receive error of the kind even the /etc/sysconfig/network-scripts/ifcfg-bond0 exists
[root@srv ~]# ifup bond0 Error: unknown connection '/etc/sysconfig/network-scripts/ifcfg-bond0'
Just remove (comment out) the line “NM_CONTROLLED=no”. The Network manager should control the interface because the Network manager parses the configuration files unless you have not installed the deprecated network scripts – network-scripts package (which is not installed and used by default and it is unknown how long will be supported).