How to configure a VLAN on top of a bond with NetworkManager

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux (RHEL) 7
  • Red Hat Enterprise Linux (RHEL) 8
  • Red Hat Enterprise Linux (RHEL) 9
  • Red Hat Enterprise Linux (RHEL) 10
  • NetworkManager (nmcli or nm-connection-editor)

Issue

  • Need an 802.1q VLAN on top of a bond in RHEL 7 when using NetworkManager
  • VLAN interface configured on top of bonding device continuously loops with setup and teardown

Resolution

The following instructions assume that ens3 and ens4 are the names of the interfaces to be used as the bond slaves. (These instructions use nmcli, but nm-connection-editor could also be used.)

  • Remove any existing connection profiles for the interfaces which will be used as the bond slaves
    Note: This will permanently remove any connections for ens3 and ens4:
# for connection in $(nmcli -t --fields name,device connection | awk -F ":" '($2 ~ "ens{3,4}") {print $1}') ; do nmcli connection delete $connection ; done
# nmcli connection reload
  • Create a bond with no IP addressing assigned:
# nmcli connection add type bond ifname bond0 con-name bond0  bond.options "mode=active-backup,miimon=100" 
# nmcli connection modify bond0 ipv4.method disabled ipv6.method ignore

# nmcli connection add type bond-slave ifname ens3 con-name ens3 master bond0
# nmcli connection add type bond-slave ifname ens4 con-name ens4 master bond0

# nmcli connection up bond0

Note:

- Change bond.options accroding to your bond mode configuration requriment 

## Example:

 - If want configure LACP configuration then use below command 

 # nmcli connection add type bond ifname bond0 con-name bond0  bond.options "mode=802.3ad,miimon=100"
  • Create a VLAN on top of bond0 with the IP addressing. The following assumes a VLAN ID of 10. Use either DHCP or set a static IP address:
### Using DHCP for IP addressing:
# nmcli connection add type vlan ifname bond0.10 con-name bond0.10 id 10 dev bond0

### With a static IP of  192.0.2.10/24 and gateway of 192.0.2.1:
# nmcli connection add type vlan ifname bond0.10 con-name bond0.10 id 10 dev bond0 ip4 192.0.2.10/24 gw4 192.0.2.1 ipv4.method manual
  • If using static addressing, you may want to also set DNS name server entries:
# nmcli connection modify bond0.10 ipv4.dns 192.0.2.8

Diagnostic Steps

  • Verify bond configuration status using below command

 #  cat  /proc/net/bonding/bond0`

Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.