FreeBSD Network Bonding and Link Aggregation

Jul 19, 2023 • FreeBSDSoftware

Network bonding, also referred to as NIC teaming, is a technology that enables the combination of multiple network interface controllers (NICs) into a single logical NIC. This process provides for failover, increased throughput, or load balancing depending upon configurations and requirements. In this context, FreeBSD has an interesting implementation referred to as link aggregation and failover. This article provides a comprehensive guide on how to work, configure, and optimize link aggregation for your FreeBSD systems.

Before we dive in, you might want to take a look at our articles on configuring network interfaces, FreeBSD kernel tuning, and introduction to FreeBSD networking. They provide fundamental knowledge to understand and follow this article better.

Link aggregation is a technique used in a high-speed networking environment to enable the fast and reliable transmission of data. It is used to combine multiple network connections in parallel to increase throughput and to provide redundancy in case one of the links fails.

Being a part of IEEE 802.3ad standard, Link Aggregation Control Protocol (LACP) in FreeBSD allows you to bundle several physical interfaces to form a single logical interface, commonly known as lagg interface.

Creating the Lagg Interface

FreeBSD does not automatically add lagg interfaces. You have to manually create them using the ifconfig command or by editing the /etc/rc.conf file. The syntax of these commands is straightforward and easy to understand. Here’s an example setting that using two ethernet interfaces, em0 and em1:

ifconfig_lagg0="laggproto lacp laggport em0 laggport em1 up"
defaultrouter="192.168.1.1"

To define this configuration permanently, add these lines to /etc/rc.conf file. Rest assured, you can add more interfaces by appending “laggport” followed by the interface name.

Removing and Addition of Ports

With LACP enabled, it’s possible to remove or add new ports without disturbing the active network:

  • To remove em1 from lagg0 instance, the command would be: ifconfig lagg0 delet em1
  • To add the interface back, use: ifconfig lagg0 laggport em1

Protocols Supported

The lagg interface supports several protocols, including failover, fec, lacp, loadbalance, roundrobin, and none.

Monitoring Lagg Interface

Use the following ifconfig command: ifconfig lagg0 to check the status of the lagg interface. This command will display a list of active physical interfaces along with their current status.

Practical Tips and Troubleshooting

  • Always keep all the interfaces’ speed and duplex settings consistent; it’s a good practice to maintain a stable aggregated link.
  • In case one of the physical ports get disconnected or fails, the LACP protocol takes care of redirecting the traffic to the working port(s). Once the failed port is back online, it will automatically be included back into the aggregated link.
  • If experiencing connectivity issues, it’s beneficial to verify the lagg interface setup, physical connectivity of all individual interfaces, and lookout for any error messages in the /var/log/messages.

While link aggregation is an effective tool to optimize networking in FreeBSD, it’s just one part of the equation. Network security is also critical. In this regard, consider using the nmap port for network security audits.

Explore our articles on FreeBSD Firewall Configuration and Implementing Firewalls and Security for an in-depth knowledge on FreeBSD security. And while maintaining your FreeBSD system, do not forget regular updates and upgrades.

Implement link aggregation in your FreeBSD systems today and enjoy the combined benefits of improved network performance and redundancy. Challenging as it may seem, with proper knowledge and practice, it’s an achievable task that yields rewarding results.


Checkout these related ports: