Bind multiple NICs using nmcli commands in Linux
Today, let's take a look at how to bind a NIC with nmcli (Network Manager Command Line Interface: Network Management Command Line Interface) in CentOS 7.x.
Nic (Interface) binding is a way to logically connect multiple NICs to allow failover or improve throughput. One way to improve server network availability is to use multiple NICs. Linux driver binding provides a way to aggregate multiple NICs into a logical binding interface. This is a new method for implementing binding, and does not affect the old binding driver in the linux kernel.
Nic binding provides two main benefits:
- High bandwidth
- Redundancy/Elasticity
Now let's configure Nic binding on CentOS 7. We need to decide which interfaces to configure as a Team interface ).
Run the ip link command to view available interfaces in the system.
$ ip link
Here we use eno16777736 and eno33554960 NICs to create a group interface in active backup mode. (Note: For details about different modes, refer to seven bond modes of multiple NICs)
Use the nmcli command to create a connection for the Network Group interface according to the following syntax.
# nmcli con add type team con-name CNAME ifname INAME [config JSON]
CNAME indicates the connection name. INAME is the interface name. JSON (JavaScript Object Notation) specifies the runner used ). The JSON syntax format is as follows:
'{"runner":{"name":"METHOD"}}'
METHOD is one of the following: broadcast, activebackup, roundrobin, loadbalance, or lacp.
1. Create a group Interface
Now let's create a group interface. This is the command used to create a group interface.
# nmcli con add type team con-name team0 ifname team0 config '{"runner":{"name":"activebackup"}}'
Run the # nmcli con show command to verify the configuration of the group interface.
# nmcli con show
2. Add a Slave Device
Now let's add team0 from the device to the master device. Here is the syntax for adding a slave device:
# nmcli con add type team-slave con-name CNAME ifname INAME master TEAM
Here we add eno16777736 and eno33554960 as the slave device of the team0 interface.
# nmcli con add type team-slave con-name team0-port1 ifname eno16777736 master team0
# nmcli con add type team-slave con-name team0-port2 ifname eno33554960 master team0
Run the # nmcli con show command again to verify the connection configuration. Now we can see the device configuration information.
#nmcli con show
3. assign an IP address
The above command will create the required configuration file in the/etc/sysconfig/network-scripts/directory.
Now let's assign an IP address for the team0 interface and enable this connection. This is the command for IP Address allocation.
# nmcli con mod team0 ipv4.addresses "192.168.1.24/24 192.168.1.1"
# nmcli con mod team0 ipv4.method manual
# nmcli con up team0
4. Verify binding
Run the # ip add show team0 command to verify the IP address information.
#ip add show team0
Now, use the teamdctl command to check the active backup configuration function.
# teamdctl team0 state
Now let's disconnect the activated port and check the status again to check whether the active backup configuration works as expected.
# nmcli dev dis eno33554960
Disconnect the activation port and run the command # teamdctl team0 state again to check the status.
# teamdctl team0 state
Yes, it runs well !! We will use the following command to connect back to the disconnected connection of team0.
#nmcli dev con eno33554960
We also have a teamnl command to display some options of the teamnl command.
Run the following command to check the port running on team0.
# teamnl team0 ports
Display the active port of team0.
# teamnl team0 getoption activeport
Okay, we have successfully configured the NIC binding :-). If you have any feedback, please let us know.
How to Implement Dual IP addresses for a single Nic In Ubuntu
Assign multiple IP addresses to a network card on CentOS 7
Linux dual-nic binding practices
CentOS/Linux dual-nic is bound to a single IP address, and nic hot standby
Bind a single IP address to a dual-nic in Linux [CentOS]
This article permanently updates the link address: