How to check if network bonding is configured in Linux

LinuxLinuxBeginner
Practice Now

Introduction

In this lab, you will learn how to check if network bonding is configured on a Linux system. Network bonding combines multiple network interfaces for increased bandwidth and redundancy. You will explore three key methods: examining the /proc/net/bonding filesystem to view bonding status and details, using the ip link command to verify the presence of bonded interfaces, and inspecting configuration files in /etc/network to understand how bonding is set up.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("Linux")) -.-> linux/RemoteAccessandNetworkingGroup(["Remote Access and Networking"]) linux(("Linux")) -.-> linux/BasicFileOperationsGroup(["Basic File Operations"]) linux/BasicFileOperationsGroup -.-> linux/ls("Content Listing") linux/BasicFileOperationsGroup -.-> linux/cat("File Concatenating") linux/RemoteAccessandNetworkingGroup -.-> linux/ifconfig("Network Configuring") linux/RemoteAccessandNetworkingGroup -.-> linux/ip("IP Managing") subgraph Lab Skills linux/ls -.-> lab-558798{{"How to check if network bonding is configured in Linux"}} linux/cat -.-> lab-558798{{"How to check if network bonding is configured in Linux"}} linux/ifconfig -.-> lab-558798{{"How to check if network bonding is configured in Linux"}} linux/ip -.-> lab-558798{{"How to check if network bonding is configured in Linux"}} end

Check bonding status with cat /proc/net/bonding

In this step, you will learn how to check the status of network bonding on a Linux system. Network bonding (also known as link aggregation or teaming) is a technique used to combine multiple network interfaces into a single logical interface. This can provide increased bandwidth and redundancy.

The Linux kernel provides information about network bonding through the /proc filesystem. The /proc filesystem is a virtual filesystem that provides information about processes and other system information.

To check the bonding status, you can use the cat command to display the contents of the /proc/net/bonding/ directory. This directory contains files for each configured bonding interface.

First, let's see what bonding interfaces are configured. Type the following command in your terminal and press Enter:

ls /proc/net/bonding/

If there are bonding interfaces configured, you will see a list of files, typically named bond0, bond1, etc. If the directory is empty or doesn't exist, it means no bonding interfaces are currently configured.

Now, let's view the status of a specific bonding interface. Assuming you saw a file named bond0 in the previous step, you can view its status by typing:

cat /proc/net/bonding/bond0

If bond0 exists, you will see detailed information about the bonding interface, including:

  • Bonding Mode: The mode of operation (e.g., Round Robin, Active-Backup).
  • Primary Slave: The primary network interface in the bond.
  • Currently Active Slave: The currently active network interface.
  • Slave Interface: A list of the network interfaces included in the bond and their status.

If you received an error like "No such file or directory", it means the bond0 interface does not exist in this environment. This is expected in some lab environments where bonding is not pre-configured. The important part is understanding how to check if it were configured.

Understanding the output of cat /proc/net/bonding/bond0 is crucial for troubleshooting network connectivity issues related to bonding.

Click Continue to proceed to the next step.

In the previous step, you learned how to check the bonding status using the /proc filesystem. Another essential command for inspecting network interfaces, including bonded interfaces, is the ip command, specifically ip link.

The ip command is a powerful utility for showing and manipulating routing, network devices, policy routing, and tunnels. The ip link subcommand deals with network interfaces.

To list all network interfaces on your system, including physical interfaces and any configured bonding interfaces, type the following command in your terminal and press Enter:

ip link show

You will see a list of network interfaces. Each interface will have a number, its name (like eth0, lo, or bond0), and its state (e.g., UP, DOWN).

Look for interfaces named bondX (where X is a number, like bond0). If bonding is configured, you will see one or more entries for these bonded interfaces.

For example, the output might look something like this (output will vary depending on the environment):

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff
3: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff

In this example output, bond0 is listed as a network interface with the state UP. The MASTER flag indicates that this is a bonding master interface.

The ip link show command provides a quick overview of all interfaces and their current state, which is very useful for verifying the presence and status of bonded interfaces.

Click Continue to move on.

Inspect bonding config in /etc/network

In the previous steps, you learned how to check the runtime status of bonding interfaces using /proc/net/bonding and ip link. Now, let's look at where the configuration for these interfaces is typically stored on Debian-based systems like Ubuntu.

Network interface configurations are often found in the /etc/network/interfaces file or within files in the /etc/network/interfaces.d/ directory. These files define how network interfaces are configured when the system starts.

To inspect the main network configuration file, /etc/network/interfaces, you can use the cat command. Since this file requires root privileges to modify, you might need sudo to view it in some environments, although cat usually works without sudo for reading.

Type the following command in your terminal and press Enter:

cat /etc/network/interfaces

You will see the contents of the file. This file defines network interfaces like lo (loopback) and potentially other interfaces. Look for lines that define a bond interface, such as:

auto bond0
iface bond0 inet dhcp
    bond-mode 4
    bond-slaves eth0 eth1

This is an example configuration snippet. auto bond0 means the interface should be brought up automatically. iface bond0 inet dhcp configures bond0 to get an IP address via DHCP. bond-mode 4 specifies the bonding mode (Mode 4 is 802.3ad Dynamic Link Aggregation). bond-slaves eth0 eth1 lists the physical interfaces that are part of this bond.

Additionally, configuration might be split into separate files in the /etc/network/interfaces.d/ directory. You can list the files in this directory using ls:

ls /etc/network/interfaces.d/

If there are files in this directory, you can view their contents using cat as well. For example, if you see a file named 50-cloud-init.cfg, you can view it with:

cat /etc/network/interfaces.d/50-cloud-init.cfg

Inspecting these configuration files helps you understand how the bonding interfaces are set up persistently on the system.

Click Continue to finish this lab.

Summary

In this lab, you learned how to check if network bonding is configured on a Linux system. You explored the /proc/net/bonding directory to identify existing bonding interfaces and used cat to view detailed status information for a specific bond, including its mode, active slave, and the status of its member interfaces.

You also learned how to verify the presence of bonded interfaces using the ip link command, which displays network device information, and how to inspect configuration files in /etc/network (or similar locations depending on the distribution) to understand how bonding is set up persistently. These steps provide a comprehensive approach to determining the configuration and status of network bonding in Linux.