7.4. Using the Command Line Interface (CLI)
A bond is created using the
bonding
kernel module and a special network interface called a channel bonding interface.
7.4.1. Check if Bonding Kernel Module is Installed Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
In Red Hat Enterprise Linux 7, the bonding module is not loaded by default. You can load the module by issuing the following command as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
This activation will not persist across system restarts. See the Red Hat Enterprise Linux Kernel Administration Guide for an explanation of persistent module loading. Note that given a correct configuration file using the
root
:
modprobe --first-time bonding
~]# modprobe --first-time bonding
BONDING_OPTS
directive, the bonding module will be loaded as required and therefore does not need to be loaded separately.
To display information about the module, issue the following command:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
See the
modinfo bonding
~]$ modinfo bonding
modprobe(8)
man page for more command options.
7.4.2. Create a Channel Bonding Interface Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To create a channel bonding interface, create a file in the
/etc/sysconfig/network-scripts/
directory called ifcfg-bondN
, replacing N with the number for the interface, such as 0
.
The contents of the file can be based on a configuration file for whatever type of interface is getting bonded, such as an Ethernet interface. The essential differences are that the
DEVICE
directive is bondN
, replacing N with the number for the interface, and TYPE=Bond
. In addition, set BONDING_MASTER=yes
.
Example 7.1. Example ifcfg-bond0 Interface Configuration File
An example of a channel bonding interface.
The NAME directive is useful for naming the connection profile in NetworkManager. ONBOOT says whether the profile should be started when booting (or more generally, when auto-connecting a device).
Important
Parameters for the bonding kernel module must be specified as a space-separated list in the
BONDING_OPTS="bonding parameters"
directive in the ifcfg-bondN
interface file. Do not specify options for the bonding device in /etc/modprobe.d/bonding.conf
, or in the deprecated /etc/modprobe.conf
file.
The
max_bonds
parameter is not interface specific and should not be set when using ifcfg-bondN
files with the BONDING_OPTS
directive as this directive will cause the network scripts to create the bond interfaces as required.
For further instructions and advice on configuring the bonding module and to view the list of bonding parameters, see Section 7.7, “Using Channel Bonding”.
Note that if the
NM_CONTROLLED="no"
setting is not present, NetworkManager might override settings in this configuration file.
7.4.3. Creating Port Interfaces Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The channel bonding interface is the controller (also refered to as
master
) and the interfaces to be bonded are referred to as the ports (slaves
). After the channel bonding interface is created, the network interfaces to be bound together must be configured by adding the MASTER
and SLAVE
directives to the configuration files of the ports. The configuration files for each of the port interfaces can be nearly identical.
Example 7.2. Example Port Interface Configuration File
For example, if two Ethernet interfaces are being channel bonded,
enp1s0
and enp2s0
, they can both look like the following example:
In this example, replace device_name with the name of the interface. Note that if more than one profile or configuration file exists with
ONBOOT=yes
for an interface, they may race with each other and a plain TYPE=Ethernet
profile may be activated instead of a bond port.
Note
Note that if the
NM_CONTROLLED="no"
setting is not present, NetworkManager might override settings in this configuration file.
7.4.4. Activating a Channel Bond Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
To activate a bond, open all the ports. As
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
root
, issue the following commands:
ifup ifcfg-enp1s0
~]# ifup ifcfg-enp1s0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/7)
ifup ifcfg-enp2s0
~]# ifup ifcfg-enp2s0
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/8)
Note that if editing interface files for interfaces which are currently “up”, set them down first as follows:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
Then when complete, open all the ports, which will open the bond (provided it was not set “down”).
ifdown device_name
ifdown device_name
To make NetworkManager aware of the changes, issue a command for every changed interface as
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
Alternatively, to reload all interfaces:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
The default behavior is for NetworkManager not to be aware of the changes and to continue using the old configuration data. This is set by the
root
:
nmcli con load /etc/sysconfig/network-scripts/ifcfg-device
~]# nmcli con load /etc/sysconfig/network-scripts/ifcfg-devicenmcli con load /etc/sysconfig/network-scripts/ifcfg-device
nmcli con reload
~]# nmcli con reload
monitor-connection-files
option in the NetworkManager.conf
file. See the NetworkManager.conf(5)
manual page for more information.
To view the status of the bond interface, issue the following command:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
7.4.5. Creating Multiple Bonds Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
In Red Hat Enterprise Linux, for each bond a channel bonding interface is created including the
BONDING_OPTS
directive. This configuration method is used so that multiple bonding devices can have different configurations. To create multiple channel bonding interfaces, proceed as follows:
- Create multiple
ifcfg-bondN
files with theBONDING_OPTS
directive; this directive will cause the network scripts to create the bond interfaces as required. - Create, or edit existing, interface configuration files to be bonded and include the
SLAVE
directive. - Assign the interfaces to be bonded, the port interfaces, to the channel bonding interfaces by means of the
MASTER
directive.
Example 7.3. Example multiple ifcfg-bondN interface configuration files
The following is an example of a channel bonding interface configuration file:
Copy to Clipboard
Copied!
Toggle word wrap
Toggle overflow
In this example, replace N with the number for the bond interface. For example, to create two bonds create two configuration files,
ifcfg-bond0
and ifcfg-bond1
, with appropriate IP
addresses.
Create the interfaces to be bonded as per Example 7.2, “Example Port Interface Configuration File” and assign them to the bond interfaces as required using the
MASTER=bondN
directive. For example, continuing on from the example above, if two interfaces per bond are required, then for two bonds create four interface configuration files and assign the first two using MASTER=bond0
and the next two using MASTER=bond1
.