DEV Community

Cover image for [Linux] Network Services (Part 2)
Waji
Waji

Posted on • Updated on

[Linux] Network Services (Part 2)

Channel Bonding

Channel bonding combines multiple network interfaces into a single virtual interface to increase bandwidth and improve reliability

Fault Tolerance

Fault tolerance is the ability of a system to continue functioning correctly even in the event of component failure

Redundancy

Redundancy involves having multiple components that perform the same function to ensure that the system remains available and reliable even in the event of component failure

Load balancing

Load balancing distributes network traffic evenly across multiple servers or components to ensure optimal system performance and availability.

💡 I will be going through Channel Bonding in detail for this post

Channel bonding modes define how multiple physical network interfaces are combined into a single virtual interface.

The following are the different channel bonding modes, from mode 0 to mode 6:

  1. Mode 0 (Round Robin): In this mode, network traffic is evenly distributed among all available interfaces, in a rotating fashion. Each incoming packet is sent out through the next available interface in the rotation.

  2. Mode 1 (Active-Backup): In this mode, only one interface is active at a time, and the others are kept in a standby state. If the active interface fails, one of the standby interfaces takes over as the active interface.

  3. Mode 2 (XOR): In this mode, network traffic is distributed based on the result of an XOR operation between the source and destination IP addresses.

  4. Mode 3 (Broadcast): In this mode, all incoming packets are broadcast out through all available interfaces. This mode is typically used in network configurations where all nodes have access to all other nodes, and is not commonly used in modern networks.

  5. Mode 4 (802.3ad Dynamic Link Aggregation(LACP)): In this mode, network traffic is distributed based on a hashing algorithm that takes into account both the source and destination IP addresses, as well as the source and destination MAC addresses. This mode is often used in high-performance computing and data center environments to provide high-speed, highly-available network connectivity.

💡 Dynamic Link Aggregation is a method for combining multiple physical network interfaces into a single virtual interface for the purpose of improving network performance and providing high-availability connectivity

  1. Mode 5 (Balance-tlb): In this mode, network traffic is distributed based on a combination of the XOR and the Broadcasting methods. This mode provides load balancing and fault tolerance, but does not provide high-speed connectivity.

  2. Mode 6 (Balance-alb): In this mode, network traffic is distributed based on a more sophisticated algorithm that takes into account the flow of traffic, as well as the load on each interface. This mode provides load balancing, fault tolerance, and high-speed connectivity.


Hands-on (Channel Bonding)

- Mode 1

👉 Before starting, there should be 3 Network adapters for the VM

Initially, deactivate the ens33 and ens34 interfaces

ifconfig ens34 down
ifconfig ens33 down
Enter fullscreen mode Exit fullscreen mode

Backing up the network config file for ens33

mkdir /backup
mv /etc/sysconfig/network-scripts/ifcfg-ens33 /backup

ls /backup 
ifcfg-ens33
Enter fullscreen mode Exit fullscreen mode

💡 keeping a backup for the config files are important as if anything goes wrong, we can always revert back to where we began

using the nmcli command to configure the Channel Bonding

nmcli con add type bond con-name bond0 ifname bond0 mode active-backup ip4 192.168.1.100/24
Connection 'bond0' (779ba3e7-8ebe-44c7-874c-d0de64e2d248) successfully added.
Enter fullscreen mode Exit fullscreen mode

we have provided a 192.168.1.100 IP address to this channel

To edit the bond type and also giving an interface check every 0.1 second

nmcli con mod id bond0 bond.options mode=active-backup,miimon=100
Enter fullscreen mode Exit fullscreen mode

Now if we check the connections,

~ nmcli conn
NAME                UUID                                  TYPE      DEVICE 
ens32               dcfd3416-5a10-4265-9102-294e578c015e  ethernet  ens32  
bond0               779ba3e7-8ebe-44c7-874c-d0de64e2d248  bond      bond0  
ens33               3fe514bc-907a-362c-b85d-b999e6450132  ethernet  --     
Wired connection 1  2153a191-9246-3761-8425-418061b4d41a  ethernet  --   
Enter fullscreen mode Exit fullscreen mode

We will change the name for the Wired connection 1 to ens34 using the GUI

nmtui
Enter fullscreen mode Exit fullscreen mode

nmtui setting

Removing ens34 and ens33

nmcli conn del ens33
Connection 'ens33' (3fe514bc-907a-362c-b85d-b999e6450132) successfully deleted.

nmcli conn del ens34
Connection 'ens34' (2153a191-9246-3761-8425-418061b4d41a) successfully deleted.

nmcli conn
NAME   UUID                                  TYPE      DEVICE 
ens32  dcfd3416-5a10-4265-9102-294e578c015e  ethernet  ens32  
bond0  779ba3e7-8ebe-44c7-874c-d0de64e2d248  bond      bond0
Enter fullscreen mode Exit fullscreen mode

Adding the ens33 and ens34 as the slave for the logical interface bond0

nmcli conn add type bond-slave ifname ens33 con-name ens33 master bond0 
Connection 'ens33' (9c7d9ad6-2080-4774-ae2f-f0dbe0efbc7b) successfully added.

nmcli conn add type bond-slave ifname ens34 con-name ens34 master bond0 
Connection 'ens34' (a83d67db-a630-4306-949d-4f0a60921710) successfully added.

Enter fullscreen mode Exit fullscreen mode

After restarting the network manager daemon,

nmcli conn
NAME   UUID                                  TYPE      DEVICE 
ens32  dcfd3416-5a10-4265-9102-294e578c015e  ethernet  ens32  
bond0  779ba3e7-8ebe-44c7-874c-d0de64e2d248  bond      bond0  
ens33  9c7d9ad6-2080-4774-ae2f-f0dbe0efbc7b  ethernet  ens33  
ens34  a83d67db-a630-4306-949d-4f0a60921710  ethernet  ens34  
Enter fullscreen mode Exit fullscreen mode

We can also check using the ifconfig command,

ifconfig 

bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.1.100 
Enter fullscreen mode Exit fullscreen mode

bond0 running as 192.168.1.100 and MASTER

ens33: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>

ens34: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>
Enter fullscreen mode Exit fullscreen mode

ens33 and 34 shown as SLAVE interfaces

To test if the new channel bonded interfaces are working we can disconnect the ens32 network interface on the VMWare and then connect via SSH using the .100 address

After connecting to 192.168.1.100,

route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     0.0.0.0         255.255.255.0   U     300    0        0 bond0
Enter fullscreen mode Exit fullscreen mode

We can just add default gateway

route add default gw 192.168.1.2
Enter fullscreen mode Exit fullscreen mode

This will allow us to ping to 8.8.8.8

Pinging 8.8.8.8 continuously and checking the bonding file details to observe the active slave status from another CLI connected to the same IP

watch -d -n 1 "cat /proc/net/bonding/bond0"
Enter fullscreen mode Exit fullscreen mode

this will allow us to show the active slave interface in live if it changes

In this situation, if we force disconnect the ens33, the active slave will be ens34 instead of the ens33.

The same will be the case if we disconnect the ens34, the active slave will be ens33.

👉 Another way to configure channel bonding is by using the nmtui command

nmtui
Enter fullscreen mode Exit fullscreen mode

Selecting the connection type
Connection type

Selecting the active-backup mode 1
Mode for the connection

Editing the connection name and adding slaves to the bond connection
Editing the name and slaves

Configuring the IP address and the gateway
Configuring the IPv4

Top comments (0)