In this short article, we will look at how to create a bond interface and VLAN on top of it using nmcli.
In this example, I have two interfaces eth0 and eth1 which should be aggregated into a logical bond interface. Although there is a trunk, and I need to specify a VLAN ID.
First, we need to create a bond interface:
nmcli con add type bond ifname bond0 \
bond.options "mode=balance-rr,miimon=100" \
ipv4.method disabled \
ipv6.method ignore
I chose balance-rr mode. Other modes you can choose:
- active-backup
- balance-xor
- broadcast
- 802.3ad
- balance-tlb
- balance-alb
Some of them require switch configuration.
Also, I specify ipv4.method disabled and ipv6.method ignore, because I will set up IPv4 network later during VLAN creation. Otherwise, a bond interface can flap and lose packets during the IP address discovery procedure.
Next, we need to add physical interfaces to the bond:
nmcli con add type ethernet ifname eth0 master bond0
nmcli con add type ethernet ifname eth1 master bond0
Next create a VLAN interface on top of the bond and specify an IPv4 address, DNS server, and Domain:
nmcli con add type vlan con-name vlan10 \
dev bond0 \
id 10 \
ip4 192.168.10.10/24 \
gw4 192.168.10.1 \
ipv4.dns 192.168.10.5 \
ipv4.dns-search "vmik.lab"
Where:
dev – device, where VLAN will be created. In this case bond0;
id – VLAN tag (VLAN ID);
ip4 – desirable IPv4 address in CIDR format;
gw4 – default gateway;
ipv4.dns – DNS server for IPv4 network;
ipv4.dns-search – domain, if necessary.
Let’s check the created connections:
nmcli con show
NAME UUID TYPE DEVICE
eth0 7d743d6f-7257-3c96-a04b-54a61c70eb35 ethernet eth0
eth1 403bba70-084c-39de-8c7d-5e9102419de4 ethernet eth1
vlan10 c5d6b4b6-1350-4c03-b7e8-c33668db7140 vlan bond0.10
lo a537ee20-73ac-46c2-b2a0-c86c51220bd8 loopback lo
bond-bond0 bbdbde12-6fad-46e5-b07b-798632399bff bond bond0
bond-slave-eth0 c436dd43-f6f3-4ddd-8a18-e74273600797 ethernet eth0
bond-slave-eth1 9569f990-f720-4ebc-9824-afabf5cee691 ethernet eth1
From there we can see our physical interfaces and a bond interface, bond-slave, and vlan. If interfaces are connected, they will be highlighted.
That’s all.