FreeBSD has lagg – link aggregation and link failover interface. The lagg interface allows aggregation of multiple network interfaces as one virtual lagg interface for the purpose of providing fault-tolerance and high-speed links.
How do I load lagg driver?
First, you need to load the lagg driver into the memory. To load the driver as a module at boot time, place the following line in loader.conf:
Type the following command to add line to /boot/loader.conf file, enter:
# echo 'if_lagg_load="YES"' >> /boot/loader.conf
To load driver for current session use kldload command, type:
# kldload if_lagg
A note about custom FreeBSD kernels
If you have custom compiled kernel, you need to compile this driver into the kernel, place the following line in your FreeBSD kernel configuration file:
How do I create a lagg interface?
A lagg interface can be created using the following command:
# ifconfig laggN create
# ifconfig lagg0 create
It can use different link aggregation protocols specified using the laggproto proto option. The driver currently supports the following aggregation protocols:
|failover||Sends and receives traffic only through the master port. If the master port becomes unavailable, the next active port is used. The first interface added is the master port; any interfaces added after that are used as failover devices.|
|fec||Supports Cisco EtherChannel. This is a static setup and does not negotiate aggregation with the peer or exchange frames to monitor the link.|
|lacp||Supports the IEEE 802.3ad Link Aggregation Control Protocol (LACP) and the Marker Protocol. LACP will negotiate a set of aggregable links with the peer in to one or more Link Aggregated Groups. Each LAG is composed of ports of the same speed, set to full-duplex operation. The traffic will be balanced across the ports in the LAG with the greatest total speed, in most cases there will only be one LAG which contains all ports. In the event of changes in physical connectivity, Link Aggregation will quickly converge to a new configuration.|
|loadbalance||Balances outgoing traffic across the active ports based on hashed protocol header information and accepts incoming traffic from any active port. This is a static setup and does not negotiate aggregation with the peer or exchange frames to monitor the link. The hash includes the Ethernet source and destination address, and, if available, the VLAN tag, and the IP source and destination address.|
|roundrobin||Distributes outgoing traffic using a round-robin scheduler through all active ports and accepts incoming traffic from any active port.|
|none||This protocol is intended to do nothing: it disables any traffic without disabling the lagg interface itself.|
An Example – Create link aggregation using LACP
To create a 802.3ad link aggregation using LACP with two em Intel PRO/1000 Gigabit Ethernet adapter driver Gigabit Ethernet interfaces use the following procedure. First, you do not need to assign any IPs to em0 and em1 interfaces. Do not configure them via /etc/rc.conf. Next, bring up both interfaces, enter:
# ifconfig em0 up
# ifconfig em1 up
Create a lagg interface called lagg0, enter:
# ifconfig lagg0 create
Finally, assign an IP address to lagg0:
# ifconfig lagg0 laggproto lacp laggport em0 laggport em1 10.24.116.2 netmask 255.255.255.192
If you need to create failover between NIC instead of lacp , enter:
# ifconfig lagg0 up laggproto failover laggport em0 laggport em1 10.24.116.2 netmask 255.255.255.192
To verify status of your links, enter:
You may also need to add a default gateway, enter:
# route add default 10.24.116.100
# netstat -nr
- lagg0 : Bounding interface name.
- laggproto lacp : Bounding protocol. See above tables for possible values.
- laggport em0 : Your first Ethernet interface name.
- laggport em1 : Your second Ethernet interface name.
- 10.24.116.2 : IP address for lagg0 interface.
- netmask 255.255.255.192 : Netmask address for lagg0 interface.
How do I create an active failover interface?
The following example uses an active failover interface to set up roaming between wired and wireless networks using two network devices. Whenever the wired master interface is unplugged, the wireless failover device will be used:
# ifconfig em0 up
# ifconfig ath0 nwid my_ssid up
# ifconfig lagg0 laggproto failover laggport em0 laggport ath0 192.168.1.1 netmask 255.255.255.0
How do I make link aggregation configuration persistent?
To make link aggregation configuration persistent use cloned_interfaces variable in /etc/rc.conf. Open /etc/rc.conf file, enter:
# vi /etc/rc.conf
Append the following configuration:
ifconfig_lagg0="laggproto failover laggport em0 laggport em1"
Save and close the file. Now, FreeBSD will remember your configuration after the system reboot.
The research for this FAQ is based upon the following man pages:
- rc.conf, ifconfig, and lagg
- Debian Linux: Configure Network Interfaces As A Bridge / Network Switch
- OpenBSD: Configure Network Interface As A Bridge / Network Switch
- How To PFSense Configure Network Interface As A Bridge / Network Switch
- FreeBSD: NIC Bonding / Link Aggregation / Trunking / Link Failover
- How To Setup Bridge (br0) Network on Ubuntu Linux 14.04 and 16.04 LTS
- Ubuntu setup a bonding device and enslave eth0+eth2
- Setup Bonded (bond0) and Bridged (br0) Networking On Ubuntu
- Ubuntu 20.04 add network bridge (br0) with nmcli command
- CentOS 8 add network bridge (br0) with nmcli command
- How to add network bridge with nmcli (NetworkManager) on Linux
- Set up and configure network bridge on Debian Linux
🐧 Get the latest tutorials on Linux, Open Source & DevOps via:
|Category||List of Unix and Linux commands|
|Firewall||Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04|
|Network Utilities||dig • host • ip • nmap|
|OpenVPN||CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04|
|Package Manager||apk • apt|
|Processes Management||bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time|
|Searching||grep • whereis • which|
|User Information||groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w|
|WireGuard VPN||Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04|