FreeBSD Link Aggregation (LAGG) with DHCP: Complete Configuration Guide

Discuss Wi-Fi setups, cybersecurity, and network troubleshooting.
Post Reply
User avatar
ccb056
Site Administrator
Posts: 981
Joined: January 14th, 2004, 11:36 pm
Location: Texas
Contact:

FreeBSD Link Aggregation (LAGG) with DHCP: Complete Configuration Guide

Post by ccb056 »

FreeBSD Link Aggregation (LAGG) with DHCP: Complete Configuration Guide

This tutorial will walk you through setting up Link Aggregation (LAGG) on FreeBSD with DHCP configuration. Link aggregation combines multiple network interfaces into a single logical interface for increased bandwidth and redundancy.

Prerequisites
  • FreeBSD system with at least two network interfaces
  • Root or sudo access
  • Physical access or console access (in case network configuration fails)
What You’ll Learn
  • How to enable the lagg kernel module
  • Configure persistent LAGG setup using /etc/rc.conf
  • Set up DHCP on the aggregated interface
  • Verify and troubleshoot your configuration
Step 1: Enable the LAGG Kernel Module

The first step is ensuring FreeBSD loads the link aggregation driver at boot time.

Code: Select all

echo 'if_lagg_load="YES"' >> /boot/loader.conf
This command appends the lagg module loading directive to your boot configuration. The module provides the link aggregation functionality needed for combining network interfaces.

Step 2: Configure Network Settings in /etc/rc.conf

Next, you’ll configure the persistent network settings. Open /etc/rc.conf in your preferred editor:

Code: Select all

vi /etc/rc.conf
Add the following configuration:

Code: Select all

# Individual interface configuration - bring them up without IP addresses
ifconfig_igb0="up"
ifconfig_em0="up"

# Create the lagg interface
cloned_interfaces="lagg0"

# Configure lagg0 with loadbalance protocol and DHCP
ifconfig_lagg0="laggproto loadbalance laggport igb0 laggport em0 DHCP"

# Optional: IPv6 configuration
ifconfig_lagg0_ipv6="inet6 accept_rtadv"
Note: Replace igb0 and em0 with your actual interface names. You can find these using ifconfig -a.

Step 3: Understanding the Configuration

Let’s break down what each configuration line does:

Physical Interface Configuration

Code: Select all

ifconfig_igb0="up"
ifconfig_em0="up"
These lines bring up the physical interfaces without assigning IP addresses. The interfaces must be active but unconfigured for LAGG to work properly.

Creating the Virtual Interface

Code: Select all

cloned_interfaces="lagg0"
This creates a virtual interface named lagg0 at boot time. Think of it as the container that will hold your aggregated links.

LAGG Configuration

Code: Select all

ifconfig_lagg0="laggproto loadbalance laggport igb0 laggport em0 DHCP"
This complex line does several things:- laggproto loadbalance: Sets the aggregation protocol to load balancing mode- laggport igb0 laggport em0: Adds both physical interfaces to the LAGG- DHCP: Configures the LAGG interface to obtain an IP address via DHCP

Available LAGG Protocols

FreeBSD supports several aggregation protocols:- loadbalance: Distributes traffic across all active ports- failover: Uses primary interface, switches to backup on failure- lacp: IEEE 802.3ad Link Aggregation Control Protocol- roundrobin: Distributes packets in round-robin fashion- broadcast: Sends all traffic on all ports

Step 4: Apply the Configuration

You have two options to activate your new configuration:

Option 1: Restart Network Services (Use with Caution)

If you have console access or are confident in your configuration:

Code: Select all

service netif restart && service routing restart
Warning: This will temporarily disconnect all network connections. Don’t use this over SSH unless you have alternate access.

Option 2: Reboot the System (Recommended)

The safer approach is to reboot:

Code: Select all

reboot
This ensures all settings are applied cleanly during the boot process.

Step 5: Verify Your Configuration

After the system boots, verify everything is working correctly.

Check LAGG Interface Status

Code: Select all

ifconfig lagg0
Expected output should look similar to:

Code: Select all

lagg0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=...
        ether ac:1f:6b:7f:46:07
        inet 192.168.11.120 netmask 0xffffff00 broadcast 192.168.11.255
        media: Ethernet autoselect
        status: active
        laggproto loadbalance lagghash l2,l3,l4
        laggport: igb0 flags=1c<ACTIVE,COLLECTING,DISTRIBUTING>
        laggport: em0 flags=1c<ACTIVE,COLLECTING,DISTRIBUTING>
Key indicators of success:- status: active - The interface is operational- Both ports show ACTIVE,COLLECTING,DISTRIBUTING flags- An IP address is assigned (from DHCP)

Verify All Interfaces

Check the status of all network interfaces:

Code: Select all

ifconfig
Your physical interfaces (igb0, em0) should show as UP but without IP addresses.

Check DHCP Lease Information

Code: Select all

cat /var/db/dhclient.leases.lagg0
This shows the DHCP lease details for your LAGG interface.

Troubleshooting

Common Issues and Solutions

LAGG interface not getting DHCP address:- Verify physical interfaces are connected and have link- Check switch configuration if using LACP- Ensure DHCP server is accessible from the network segment

One port shows as not active:- Check physical cable connections- Verify the interface is up: ifconfig igb0 up- Look for errors in /var/log/messages

Performance not improved:- Load balancing depends on traffic patterns- Single TCP connections won’t be split across links- Consider different hash algorithms: sysctl net.link.lagg.default_lagghash

Monitoring LAGG Performance

Monitor traffic distribution across ports:

Code: Select all

# Show statistics for each port
netstat -I lagg0 -w 1
Advanced Configuration

Static IP Instead of DHCP

If you prefer a static IP configuration:

Code: Select all

ifconfig_lagg0="laggproto loadbalance laggport igb0 laggport em0 inet 192.168.1.100 netmask 255.255.255.0"
defaultrouter="192.168.1.1"
Adding More Interfaces

To add additional interfaces to the LAGG:

Code: Select all

ifconfig_lagg0="laggproto loadbalance laggport igb0 laggport em0 laggport em1 DHCP"
VLAN Support

LAGG interfaces support VLANs:

Code: Select all

cloned_interfaces="lagg0 vlan100"
ifconfig_vlan100="vlan 100 vlandev lagg0 inet 10.100.0.10/24"
Best Practices
  1. Test Before Production: Always test LAGG configuration in a non-production environment first
  2. Document Your Setup: Keep records of interface names and configurations
  3. Monitor Regularly: Set up monitoring to detect if a link fails
  4. Plan for Failures: Understand how your chosen protocol handles link failures
  5. Switch Configuration: Ensure your network switch supports and is configured for your chosen LAGG protocol
Conclusion

You now have a fully functional link aggregation setup on FreeBSD with DHCP configuration. This setup provides increased bandwidth potential and network redundancy. Remember to monitor your configuration and adjust the aggregation protocol based on your specific needs and network environment.

For more advanced configurations and options, consult the FreeBSD handbook and the lagg(4) man page.
Post Reply