OSPF is a link-state interior gateway protocol that builds a complete topology database and calculates shortest paths using Dijkstra's algorithm, providing fast convergence and load balancing capabilities.
RouterOS v7+ includes an enhanced OSPF implementation with improved performance, better scalability, and support for modern OSPF features including graceful restart and traffic engineering extensions.
OSPF fundamentals
How OSPF works
Link-state operation:
Each router maintains complete network topology database
Routers exchange Link State Advertisements (LSAs)
Shortest Path First (SPF) algorithm calculates optimal paths
Hierarchical area design provides scalability
Key concepts:
Areas - Logical subdivisions that limit LSA flooding scope
Router ID - Unique identifier for each OSPF router
Cost - Metric based on bandwidth (100Mbps/interface bandwidth)
Designated Router (DR) - Reduces LSA flooding on broadcast networks
Adjacencies - Full neighbor relationships for LSA synchronization
OSPF advantages
Fast convergence:
Sub-second convergence with proper tuning
Immediate detection of link failures
Incremental SPF calculations for efficiency
Scalability features:
Area hierarchy reduces routing overhead
Route summarization at area boundaries
Support for thousands of routes
Load balancing:
Equal-Cost Multi-Path (ECMP) support
Automatic load distribution across equal paths
Unequal cost load balancing with careful design
Basic OSPF configuration
Single area OSPF
Simple OSPF deployment for small to medium networks:
Multi-area OSPF
Hierarchical OSPF design for larger networks:
Advanced OSPF features
OSPF area types
Different area types for optimization:
OSPF authentication
Secure OSPF communications:
OSPF route filtering and summarization
Control route advertisement and summarization:
OSPF network types
Point-to-Point networks
Direct connections between two routers:
Broadcast networks
Ethernet LANs with multiple routers:
NBMA and Point-to-Multipoint
Non-broadcast networks (Frame Relay, etc.):
OSPF performance tuning
Convergence optimization
Tune OSPF for faster convergence:
Scalability optimization
Configure OSPF for large-scale deployments:
OSPF monitoring and troubleshooting
Monitoring OSPF health
Track OSPF performance and status:
Troubleshooting procedures
Systematic OSPF troubleshooting approach:
OSPF design best practices
Network design principles
Hierarchical design - Always use Area 0 as backbone, connect other areas to it
Area sizing - Keep areas under 50 routers for optimal performance
Router ID planning - Use loopback addresses or planned IDs for stability
Cost planning - Design consistent cost metrics for predictable paths
Redundancy design - Multiple ABRs between areas for resilience
Configuration guidelines
Authentication - Always enable OSPF authentication in production
Timer consistency - Ensure consistent hello/dead intervals per network
Area types - Use stub areas to reduce routing overhead where appropriate
Summarization - Implement route summarization at area boundaries
Filtering - Control route advertisement with appropriate filters
Operational practices
Monitor actively - Track neighbor states and convergence times
Document topology - Maintain current network diagrams and area designs
Test changes - Verify OSPF behavior after configuration changes
Capacity planning - Monitor LSA database growth and CPU utilization
Backup configuration - Regular backups of OSPF configuration
# OSPF network topology example
#
# Area 0 (Backbone)
# Router1 ---- Router2
# | |
# Area 1 Area 2
# (Marketing) (Engineering)
#
# Each area maintains separate LSA database
# Area 0 connects all other areas
# Inter-area routing through Area 0 (ABR routers)
# Basic OSPF configuration for single area
# Enable OSPF instance
/routing ospf instance add name=main router-id=1.1.1.1 disabled=no comment="Main OSPF instance"
# Create backbone area (Area 0)
/routing ospf area add name=backbone area-id=0.0.0.0 instance=main comment="OSPF backbone area"
# Add interfaces to OSPF
/routing ospf interface-template add area=backbone interfaces=ether1,ether2,bridge \
type=broadcast disabled=no comment="OSPF interfaces"
# Verify OSPF operation
/routing ospf neighbor print
/routing ospf lsa print
/ip route print where ospf=yes
# Check OSPF database
/routing ospf lsa print where area=backbone
# Multi-area OSPF configuration
# Router acting as Area Border Router (ABR)
# OSPF instance with unique router ID
/routing ospf instance add name=enterprise router-id=10.1.1.1 disabled=no \
comment="Enterprise OSPF"
# Backbone area (Area 0) - mandatory for multi-area OSPF
/routing ospf area add name=backbone area-id=0.0.0.0 instance=enterprise \
comment="OSPF backbone - connects all areas"
# Regular areas connected to backbone
/routing ospf area add name=sales area-id=0.0.0.1 instance=enterprise \
comment="Sales department area"
/routing ospf area add name=engineering area-id=0.0.0.2 instance=enterprise \
comment="Engineering department area"
# Interface assignments
# Backbone connections (core network)
/routing ospf interface-template add area=backbone interfaces=ether1,ether2 \
type=ptp cost=10 disabled=no comment="Backbone area interfaces"
# Sales area interfaces
/routing ospf interface-template add area=sales interfaces=ether3 \
type=broadcast cost=100 disabled=no comment="Sales area interface"
# Engineering area interfaces
/routing ospf interface-template add area=engineering interfaces=ether4 \
type=broadcast cost=100 disabled=no comment="Engineering area interface"
# Verify multi-area operation
/routing ospf area print
/routing ospf neighbor print
/routing ospf lsa print where type=summary # Inter-area routes
# Standard area (default) - accepts all LSA types
/routing ospf area add name=standard area-id=0.0.0.10 instance=main \
type=default comment="Standard area - all LSA types"
# Stub area - blocks external LSAs, reduces routing table
/routing ospf area add name=branch-offices area-id=0.0.0.20 instance=main \
type=stub default-cost=100 comment="Stub area for branch offices"
# Totally stubby area - blocks external and summary LSAs
/routing ospf area add name=access-layer area-id=0.0.0.30 instance=main \
type=stub no-summaries=yes default-cost=50 \
comment="Totally stubby area for access layer"
# Not-So-Stubby Area (NSSA) - allows limited external routes
/routing ospf area add name=regional area-id=0.0.0.40 instance=main \
type=nssa default-cost=200 comment="NSSA for regional offices"
# Interface assignments for different area types
/routing ospf interface-template add area=branch-offices interfaces=ether5 \
type=broadcast disabled=no comment="Branch office stub area"
/routing ospf interface-template add area=access-layer interfaces=ether6 \
type=broadcast disabled=no comment="Access layer totally stubby"
# Verify area types and their effect on LSA database
/routing ospf area print detail
/routing ospf lsa print where area=branch-offices # Should show fewer LSAs
/routing ospf lsa print where area=access-layer # Should show minimal LSAs
# Area-wide authentication
/routing ospf area add name=secure-area area-id=0.0.1.0 instance=main \
auth-type=md5 comment="Area with MD5 authentication"
# Interface-specific authentication (overrides area setting)
/routing ospf interface-template add area=secure-area interfaces=ether3 \
type=ptp auth-type=md5 auth-key="SecureOSPFKey123!" auth-id=1 \
disabled=no comment="Secure OSPF interface"
# Simple password authentication (less secure)
/routing ospf interface-template add area=backbone interfaces=ether7 \
type=broadcast auth-type=simple auth-key="SimplePassword" \
disabled=no comment="Simple authentication interface"
# Verify authentication is working
/routing ospf neighbor print detail # Should show authenticated neighbors
/log print where topics~"ospf" and message~"auth" # Check for auth errors
# Route filtering for OSPF
# Filter specific networks from OSPF advertisement
/routing filter rule add chain=ospf-out action=discard \
prefix=192.168.100.0/24 comment="Block test network from OSPF"
# Allow only specific networks
/routing filter rule add chain=ospf-out action=accept \
prefix=10.0.0.0/8 prefix-length=8-24 comment="Allow corporate networks"
/routing filter rule add chain=ospf-out action=discard \
comment="Block all other networks"
# Route summarization at area borders
/routing ospf area add name=branch-summary area-id=0.0.2.0 instance=main \
area-range=192.168.0.0/16 advertise=yes comment="Summarize branch networks"
# Multiple summarization ranges for different network segments
/routing ospf area set branch-summary \
area-range=192.168.0.0/16,10.100.0.0/16 \
comment="Multiple summary ranges"
# External route summarization (for redistributed routes)
/routing ospf instance set main \
asbr-summary-lsa=yes comment="Enable ASBR summary LSAs"
# Verify summarization is working
/routing ospf lsa print where type=summary # Check summary LSAs
/ip route print where ospf=yes # Verify summarized routes are installed
# Point-to-Point configuration (WAN links, dedicated connections)
/routing ospf interface-template add area=backbone interfaces=ether1 \
type=ptp cost=100 hello-interval=10s dead-interval=30s \
disabled=no comment="P2P WAN link"
# P2P characteristics:
# - No DR/BDR election needed
# - Faster convergence
# - Lower overhead
# - Suitable for WAN links
# Verify P2P operation
/routing ospf interface print where type=ptp
/routing ospf neighbor print # Should show P2P neighbors without DR election
# Broadcast network configuration (Ethernet LANs)
/routing ospf interface-template add area=backbone interfaces=bridge \
type=broadcast cost=10 priority=100 hello-interval=10s dead-interval=40s \
disabled=no comment="LAN broadcast network"
# Broadcast characteristics:
# - DR/BDR election for efficiency
# - Higher priority routers become DR
# - All routers form adjacency with DR/BDR
# - Reduces LSA flooding on multi-access networks
# Control DR election with priority
/routing ospf interface-template set [find interfaces=bridge] priority=200
# Priority 0 = never DR, higher values preferred for DR election
# Verify DR/BDR election
/routing ospf neighbor print # Check DR/BDR status
/routing ospf interface print detail # Show DR/BDR for each interface