NIC Bonding and Everything you need to know using RHEL 9
Tags: linux, devops, beginners, computerscience
Published: 2022-08-04 04:57:09

**NIC**
Network interface cards (NICs) enable computers to connect to a network by installing hardware components, usually circuit boards or chips. In addition to supporting I/O interrupts, direct memory access (DMA) interfaces, data transmission, network traffic engineering, and partitioning, modern NICs also provide computers with a number of other functions.

To find info about your NIC use the command and sign in as the root user.

`ethtool <INTERFACE_NAME>`

Now, to know your NIC name use the command ifconfig. There are several NICs like lo, virbr0, etc. but we want to take the first one that comes on. 

`ifconfig | more`


![ifconfig](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7nh3vwmwdl7o9j3k081r.png)

Here our NIC is enp0s3, Now use the command `ethtool enp0s3`


![ethtool](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vtnu69unbouhmw8jg8yo.png)

now that you have the network information, you should see a few of the things mentioned like link modes, speed, duplex, etc.

**NIC Bonding**
Now that you know what NIC is, let’s dive into NIC bonding also known as network bonding. It can be defined as the aggregation and combination of multiple NICs into a single bond interface. Its main purpose is to provide high availability and redundancy. 

**How to do NIC Bonding?**
Make sure you've enabled two or more network adapters from Virtual Box settings

- Add a new NIC if it does not exist
- Install bonding driver = modprobe bonding
- To list the bonding module info = modinfo bonding
	_You will see the driver version as seen below if the driver is installed and loaded
_


![driver](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3lwgzv1n8enzh2k31kew.png)

_Create Bond Interface File_
`vi /etc/sysconfig/network-scripts/ifcfg-bond0`

_Add the following parameters_
`DEVICE=bond0
TYPE=Bond
NAME=bond0
BONDING_MASTER=yes
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.168.1.80
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
BONDING_OPTS=”mode=5 miimon=100”`

_Save and exit the file_

The bonding options details are can be found on the following table

![NIC Bonding options](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p9mpl0omp4jeo25sw0g7.png)

**miimon** 
Specifies the MII link monitoring frequency in milliseconds. This determines how often the link state of each slave is inspected for link failures


_Edit the First NIC File (enp0s3)_
`vi /etc/sysconfig/network-scripts/ifcfg-enp0s3`

_Delete the entire content
Add the following parameters_

`TYPE=Ethernet
BOOTPROTO=none
DEVICE=enp0s3
ONBOOT=yes
HWADDR=”MAC from the ifconfig command”
MASTER=bond0
SLAVE=yes`

_Save and exit the file_

_Create the Second NIC File (enp0s8) or Copy enp0s3_
`vi /etc/sysconfig/network-scripts/ifcfg-enp0s8`

_Add the following parameters_
`TYPE=Ethernet
BOOTPROTO=none
DEVICE=enp0s8
ONBOOT=yes
HWADDR=”MAC from the ifconfig command”
MASTER=bond0
SLAVE=yes`
_Save and exit the file_

_Restart the Network Service_
`systemctl restart network`

_Test and verify the configuration_
`ifconfig` 	or 	`ifconfig | more`

_Use following command to view bond interface settings like bonding mode & slave interface
_
`cat /proc/net/bonding/bond0
`

That NIC Bonding complete overview on Red Hat Enterprise Linux operating system 9. If you like it do give a follow!