Configure VLAN Tagging on top of LACP Network Bonding using nmcli
In enterprise IT infrastructure, it is common to use LACP Network Bonding and VLAN Tagging.
LACP network bonding allows two or more network interfaces to be aggregated as one, thereby providing increased bandwidth and interface / cable redundancy.
VLAN Tagging allows traffics from different networks to share common physical links while being kept segregated.
To configure both in a Linux server, it is common to use nmcli
. Basically, it is a two steps configuration:
- Configure a network bonding interface to aggregate underlying network interfaces.
- Configure a VLAN tagged interface on top of the network bonding interface.
Below provides an example to configure these using nmcli
on CentOS / RHEL.
Pre-requisites
Ensure to have the 8021q
module enabled for LACP.
modprobe --first-time 8021q
modinfo 8021q
Configure Network Bonding
This example adds a network bonding interface named bond0
with two network interfaces named enP48p1s0f0
and enp1s0f0
.
Create the bond0
bonding interface using 802.3ad mode.
nmcli con add type bond ifname bond0 con-name bond0 mode 802.3ad miimon 100 downdelay 0 updelay 0 connection.autoconnect yes ipv4.method disabled ipv6.method ignore
Add the two network interfaces as slave to the bond0
bonding interface.
nmcli con add type bond-slave ifname enP48p1s0f0 con-name enP48p1s0f0 master bond0
nmcli con add type bond-slave ifname enp1s0f0 con-name enp1s0f0 master bond0
Bring up the bond0
bonding interface.
nmcli con up bond0
Check the connections created.
# nmcli con show
NAME UUID TYPE DEVICE
bond0 <masked> bond bond0
enP48p1s0f0 <masked> ethernet enP48p1s0f0
enp1s0f0 <masked> ethernet enp1s0f0
Configure VLAN Tagging
Next, a vlan
type connection shall be added on top of the bond0
device created in previous step. The TCP/IP parameters such as IP address, subnet mask, gateway, DNS and search domain are added here as well. In this example, the parameters used are:
- VLAN ID: 123
- IP address: 192.168.123.123
- Subnet mask: 255.255.255.0
- Gateway: 192.168.123.1
- DNS: 192.168.123.4, 192.168.123.5
- Search domain: example.com
nmcli con add type vlan ifname bond0.123 con-name bond0.123 id 123 dev bond0 connection.autoconnect yes ip4 192.168.123.123/24 gw4 192.168.123.1 ipv4.dns 192.168.123.4,192.168.123.5 ipv4.dns-search example.com
Bring up the bond0.123
VLAN interface.
nmcli con up bond0.123
Check the connections created.
# nmcli con show
NAME UUID TYPE DEVICE
bond0 <masked> bond bond0
bond0.123 <masked> vlan bond0.123
enP48p1s0f0 <masked> ethernet enP48p1s0f0
enp1s0f0 <masked> ethernet enp1s0f0
Verify the created VLAN interface bond0.123
is UP with IP address configured.
# ip addr show bond0.123
15: bond0.123@bond0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.123.123/24 brd 192.168.123.255 scope global noprefixroute bond0.123
valid_lft forever preferred_lft forever
inet6 xxxx::xxxx:xxxx:xxxx:xxxx/64 scope link noprefixroute
valid_lft forever preferred_lft forever