MikroTik Configuration for High Availability Network with MLAG and VRRP
This configuration provides redundancy at both the switching layer (using MLAG) and the routing layer (using VRRP). The setup consists of two switches in an MLAG configuration and two routers using VRRP for high availability.
Switch Configuration (SwA and SwB)
MLAG Peer Link Configuration
First, we need to configure the basic switch settings and establish the MLAG peer connection between the two switches via eth24.
SwA Configuration:
# Create bridge with VLAN filtering
/interface bridge add name=bridge1 vlan-filtering=yes
# Configure eth24 as the peer-port
/interface bridge port add bridge=bridge1 interface=ether24 pvid=99
# Add VLANs needed for inter-VLAN routing (assuming VLANs 10, 20, 30)
/interface bridge vlan
add bridge=bridge1 tagged=ether24 vlan-ids=10,20,30
add bridge=bridge1 tagged=ether24 vlan-ids=1
# Enable MLAG on the bridge
/interface bridge mlag set bridge=bridge1 peer-port=ether24
SwB Configuration:
# Create bridge with VLAN filtering
/interface bridge add name=bridge1 vlan-filtering=yes
# Configure eth24 as the peer-port
/interface bridge port add bridge=bridge1 interface=ether24 pvid=99
# Add VLANs needed for inter-VLAN routing
/interface bridge vlan
add bridge=bridge1 tagged=ether24 vlan-ids=10,20,30
add bridge=bridge1 tagged=ether24 vlan-ids=1
# Enable MLAG on the bridge
/interface bridge mlag set bridge=bridge1 peer-port=ether24
Router Connection Configuration
Now, we'll configure the MLAG bonding interfaces that will connect to the routers. Since the routers don't support MLAG, we'll create MLAG-enabled ports on the switches that will appear as redundant single connections to the routers.
SwA Configuration:
# Create MLAG-enabled bonding for Router1 (eth1)
/interface bonding
add mlag-id=1 mode=802.3ad name=router1-bond slaves=ether1 transmit-hash-policy=layer-2-and-3
# Create MLAG-enabled bonding for Router2 (eth2)
/interface bonding
add mlag-id=2 mode=802.3ad name=router2-bond slaves=ether2 transmit-hash-policy=layer-2-and-3
# Add bonds to bridge
/interface bridge port
add bridge=bridge1 interface=router1-bond
add bridge=bridge1 interface=router2-bond
# Configure VLANs for router connectivity
/interface bridge vlan
add bridge=bridge1 tagged=router1-bond,router2-bond vlan-ids=10,20,30
SwB Configuration:
# Create MLAG-enabled bonding for Router1 (eth1)
/interface bonding
add mlag-id=1 mode=802.3ad name=router1-bond slaves=ether1 transmit-hash-policy=layer-2-and-3
# Create MLAG-enabled bonding for Router2 (eth2)
/interface bonding
add mlag-id=2 mode=802.3ad name=router2-bond slaves=ether2 transmit-hash-policy=layer-2-and-3
# Add bonds to bridge
/interface bridge port
add bridge=bridge1 interface=router1-bond
add bridge=bridge1 interface=router2-bond
# Configure VLANs for router connectivity
/interface bridge vlan
add bridge=bridge1 tagged=router1-bond,router2-bond vlan-ids=10,20,30
Router Configuration (Router1 and Router2)
The routers will handle routing between VLANs using VRRP. We'll configure VLAN interfaces and VRRP on these interfaces.
Basic Interface Configuration
Router1 Configuration:
# Define VLANs on physical interfaces
/interface vlan
add interface=ether1 name=vlan10-eth1 vlan-id=10
add interface=ether1 name=vlan20-eth1 vlan-id=20
add interface=ether1 name=vlan30-eth1 vlan-id=30
add interface=ether2 name=vlan10-eth2 vlan-id=10
add interface=ether2 name=vlan20-eth2 vlan-id=20
add interface=ether2 name=vlan30-eth2 vlan-id=30
# Set IP addresses for the physical interfaces (non-VRRP addresses)
/ip address
add address=10.0.10.1/24 interface=vlan10-eth1
add address=10.0.20.1/24 interface=vlan20-eth1
add address=10.0.30.1/24 interface=vlan30-eth1
add address=10.0.10.2/24 interface=vlan10-eth2
add address=10.0.20.2/24 interface=vlan20-eth2
add address=10.0.30.2/24 interface=vlan30-eth2
Router2 Configuration:
# Define VLANs on physical interfaces
/interface vlan
add interface=ether1 name=vlan10-eth1 vlan-id=10
add interface=ether1 name=vlan20-eth1 vlan-id=20
add interface=ether1 name=vlan30-eth1 vlan-id=30
add interface=ether2 name=vlan10-eth2 vlan-id=10
add interface=ether2 name=vlan20-eth2 vlan-id=20
add interface=ether2 name=vlan30-eth2 vlan-id=30
# Set IP addresses for the physical interfaces (non-VRRP addresses)
/ip address
add address=10.0.10.3/24 interface=vlan10-eth1
add address=10.0.20.3/24 interface=vlan20-eth1
add address=10.0.30.3/24 interface=vlan30-eth1
add address=10.0.10.4/24 interface=vlan10-eth2
add address=10.0.20.4/24 interface=vlan20-eth2
add address=10.0.30.4/24 interface=vlan30-eth2
VRRP Configuration with Preemption
Now we'll set up VRRP between the routers with preemption enabled.
Router1 Configuration (Primary):
# Configure VRRP interfaces with higher priority (primary router)
/interface vrrp
add interface=vlan10-eth1 name=vrrp-vlan10 vrid=10 priority=254 preemption-mode=yes
add interface=vlan20-eth1 name=vrrp-vlan20 vrid=20 priority=254 preemption-mode=yes
add interface=vlan30-eth1 name=vrrp-vlan30 vrid=30 priority=254 preemption-mode=yes
# Set VRRP virtual IP addresses
/ip address
add address=10.0.10.254/32 interface=vrrp-vlan10
add address=10.0.20.254/32 interface=vrrp-vlan20
add address=10.0.30.254/32 interface=vrrp-vlan30
Router2 Configuration (Backup):
# Configure VRRP interfaces with default priority (backup router)
/interface vrrp
add interface=vlan10-eth1 name=vrrp-vlan10 vrid=10 priority=100 preemption-mode=yes
add interface=vlan20-eth1 name=vrrp-vlan20 vrid=20 priority=100 preemption-mode=yes
add interface=vlan30-eth1 name=vrrp-vlan30 vrid=30 priority=100 preemption-mode=yes
# Set VRRP virtual IP addresses
/ip address
add address=10.0.10.254/32 interface=vrrp-vlan10
add address=10.0.20.254/32 interface=vrrp-vlan20
add address=10.0.30.254/32 interface=vrrp-vlan30
Inter-VLAN Routing Configuration
For routing between VLANs, the routers will handle this automatically since they have interfaces in each VLAN and have VRRP configured.
Both Router1 and Router2:
# Enable IP routing
/ip route
# MikroTik routers automatically route between directly connected networks
# No explicit routes needed for inter-VLAN routing
Additional Considerations
-
STP Configuration: Enable RSTP on all switches to prevent loops[1].
/interface bridge settings set use-ip-firewall=no use-ip-firewall-for-vlan=no \
use-ip-firewall-for-pppoe=no protocol-mode=rstp
-
Hardware Offloading: MLAG is not compatible with L3 hardware offloading. Disable it if enabled[1].
/interface ethernet switch set 0 l3-hw-offloading=no
-
Monitor MLAG Status:
/interface bridge mlag monitor
-
Monitor VRRP Status:
/interface vrrp monitor
This configuration provides a highly available network with redundancy at both the switching and routing layers. If one switch fails, the MLAG will ensure continued connectivity. If one router fails, VRRP will ensure continued routing capabilities with minimal disruption.