-sys-class-net-bonding_masters

The /sys/class/net/bonding_masters file in Linux provides a list of all the bonding interfaces (also called bond devices) that are currently configured on the system. It contains the names of the bonding interfaces, such as bond0, bond1, etc.

This file is particularly useful for administrators or scripts to easily identify the active bonding interfaces on the system.

Example of Usage

  1. Check the current bonding interfaces on your system:

cat /sys/class/net/bonding_masters

Example Output:

bond0
bond1

This output indicates that there are two bonding interfaces, bond0 and bond1, on the system.

Explanation:

  • The /sys/class/net/bonding_masters file contains the names of all the master bonding interfaces configured on the system.

  • Each bonding interface represents a logical link aggregation device that combines multiple physical network interfaces (called slaves) to increase bandwidth or provide redundancy.

How to Create or View Bonding Interfaces:

  1. View details of a bonding interface:

For example, to check the configuration of bond0, you can look at:

cat /sys/class/net/bond0/bonding/mode

This command will show the bonding mode (e.g., active-backup, balance-rr, etc.) for bond0.

  1. Creating a bonding interface:

If you have not created a bonding interface, you can do so by editing the network configuration files or using the following commands:

# Example command for creating a bond (bond0)
sudo modprobe bonding
sudo ifconfig bond0 up

In the /etc/network/interfaces file (Debian/Ubuntu) or /etc/sysconfig/network-scripts/ifcfg-bond0 (RedHat/CentOS), you can configure the bonding interface and add slave interfaces.

Example (Debian/Ubuntu):

auto bond0
iface bond0 inet static
    address 192.168.1.100
    netmask 255.255.255.0
    bond-slaves eth0 eth1
    bond-mode 1

Summary

The /sys/class/net/bonding_masters file is a simple and efficient way to view all the bonded interfaces on your system. If you are managing network interfaces and need to ensure that multiple network interfaces are aggregated into a single virtual interface, this file helps you confirm the active bonding interfaces.

Last updated