VRF technology allows a single RouterOS device to maintain multiple separate routing tables, enabling network virtualization, multi-tenancy, and traffic isolation for complex networking scenarios.
VRF in RouterOS v7+ provides complete routing table isolation, supporting MPLS VPNs, multi-tenant networks, and advanced traffic engineering with per-VRF routing protocols and policies.
VRF fundamentals
How VRF works
Core concepts:
Virtual routing instances - Separate routing tables per VRF
Interface assignment - Interfaces belong to specific VRF instances
Route isolation - Routes in one VRF are invisible to others
Routing protocols - Each VRF can run independent routing protocols
Route targets - Control route import/export between VRFs (MPLS VPNs)
VRF benefits:
Network segmentation - Complete traffic isolation between tenants
Simplified management - Single device supporting multiple customers
Reduced hardware costs - Virtualization instead of physical separation
Flexible routing policies - Different routing policies per VRF
Service provider enablement - Foundation for MPLS L3VPNs
VRF vs traditional routing
Basic VRF configuration
Simple VRF setup
Create basic VRF instances for customer isolation:
Multi-interface VRF
VRF spanning multiple interfaces:
Advanced VRF scenarios
VRF with dynamic routing
Running routing protocols within VRF instances:
Inter-VRF route leaking
Controlled communication between VRF instances:
VRF with MPLS integration
Integrate VRF with MPLS for service provider scenarios:
VRF monitoring and management
VRF status monitoring
Track VRF performance and connectivity:
Troubleshooting VRF issues
Common VRF problems and diagnostic steps:
VRF security and isolation
Traffic isolation verification
Ensure proper VRF isolation:
VRF security policies
Implement security controls for VRF environments:
VRF best practices
Design considerations
Plan VRF hierarchy - Design logical VRF structure for scalability
Interface assignment - Carefully plan interface-to-VRF mappings
Route target strategy - Plan RT scheme for MPLS VPN environments
Shared services design - Plan controlled access to common resources
Security policies - Implement proper isolation and access controls
Performance optimization
Hardware capabilities - Verify VRF support in hardware
Routing protocol tuning - Optimize protocols per VRF requirements
Memory planning - Account for multiple routing tables
Interface optimization - Tune VRF interfaces for performance
Monitoring overhead - Plan for increased monitoring complexity
Operational guidelines
Documentation - Maintain clear VRF documentation and diagrams
# Monitor VRF instances and their interfaces
/ip route vrf print detail
# Check routes per VRF
/ip route print where routing-table=customer-a
/ip route print where routing-table=customer-b
# Monitor VRF interface status
/interface print where master-port="" and disabled=no
# Test connectivity within specific VRF
/ping 192.168.10.100 routing-table=customer-a count=5
/tool traceroute 10.10.1.1 routing-table=customer-a
# Monitor routing protocol status per VRF
/routing ospf neighbor print where instance=customer-ospf
/routing bgp session print where vrf=customer-bgp
# VRF traffic statistics
/interface monitor-traffic ether2,ether3 duration=30
# 1. Verify VRF configuration
/ip route vrf print detail
# 2. Check interface assignments
/interface print where master-port="" # Should show VRF assignments
# 3. Verify routing table contents
/ip route print where routing-table=customer-a
# 4. Test VRF connectivity
/ping 192.168.10.1 routing-table=customer-a
# 5. Check for route leaking issues
/ip route print where routing-table=customer-a and dst-address~"172.16"
# 6. Verify MPLS VPN functionality (if applicable)
/routing bgp advertisements print where peer=2.2.2.2
/ip route print where routing-table=mpls-customer and bgp=yes
# 7. Monitor for VRF-related errors
/log print where topics~"routing,bgp,ospf"
# VRF diagnostic script
:local vrfName "customer-a";
:local testDestination "192.168.10.100";
/log info ("Diagnosing VRF: " . $vrfName);
# Check VRF exists
:local vrfExists [/ip route vrf find routing-mark=$vrfName];
:if ([:len $vrfExists] > 0) do={
/log info ("VRF " . $vrfName . " is configured");
# Check routes in VRF
:local routeCount [/ip route print count-only where routing-table=$vrfName];
/log info ("VRF " . $vrfName . " has " . $routeCount . " routes");
# Test connectivity
:do {
/ping $testDestination routing-table=$vrfName count=3;
/log info ("Connectivity test to " . $testDestination . " successful");
} on-error={
/log error ("Connectivity test to " . $testDestination . " failed");
};
} else={
/log error ("VRF " . $vrfName . " not found");
};
# Test VRF isolation (should fail)
# Try to access Customer B from Customer A VRF
/ping 192.168.20.100 routing-table=customer-a # Should fail
# Test shared services access (should work if configured)
/ping 172.16.1.100 routing-table=customer-a # Should work if route leaking configured
# Verify routing table separation
/ip route print where routing-table=customer-a
/ip route print where routing-table=customer-b
# Routes should be completely separate
# Check for accidental route leaking
/ip route print where routing-table=customer-a and dst-address~"192.168.20"
# Should return no results (Customer B networks shouldn't be in Customer A VRF)
# Firewall rules for VRF security
# Block inter-VRF communication at firewall level
/ip firewall filter add chain=forward \
in-interface-list=customer-a-interfaces \
out-interface-list=customer-b-interfaces \
action=drop comment="Block Customer A to Customer B"
/ip firewall filter add chain=forward \
in-interface-list=customer-b-interfaces \
out-interface-list=customer-a-interfaces \
action=drop comment="Block Customer B to Customer A"
# Create interface lists for VRF management
/interface list add name=customer-a-interfaces comment="Customer A VRF interfaces"
/interface list add name=customer-b-interfaces comment="Customer B VRF interfaces"
# Add interfaces to appropriate lists
/interface list member add list=customer-a-interfaces interface=ether2
/interface list member add list=customer-b-interfaces interface=ether3
# Allow controlled access to shared services
/ip firewall filter add chain=forward \
in-interface-list=customer-a-interfaces \
dst-address=172.16.0.0/16 protocol=tcp dst-port=53,123 \
action=accept comment="Allow Customer A to shared services"
# Log VRF violations for security monitoring
/ip firewall filter add chain=forward \
in-interface-list=customer-a-interfaces \
out-interface-list=customer-b-interfaces \
action=log log-prefix="VRF-VIOLATION-A-to-B"
# NAT policies per VRF (if needed for internet access)
/ip firewall nat add chain=srcnat \
out-interface=wan-interface \
src-address=192.168.10.0/24 \
action=masquerade comment="Customer A NAT"
/ip firewall nat add chain=srcnat \
out-interface=wan-interface \
src-address=192.168.20.0/24 \
action=masquerade comment="Customer B NAT"