Tutorials · Switching
How to Configure OSPF Dynamic Routing Between Layer 3 Switches
Replace dozens of static routes with OSPF: plan areas and router IDs, advertise networks, secure neighbours with authentication, tune timers and verify convergence.
Before you start
- Two or more Layer 3 switches or routers with OSPF support (check the datasheet)
- A routed link (transit VLAN or /30–/31) between each pair
- A diagram of subnets per site
Step by step
Understand when OSPF helps
Static routes are fine for one or two sites. With several buildings, a campus core or redundant links, OSPF learns routes automatically and reroutes when a link fails. All switches in one area share the same map of the network.
Plan area 0 and router IDs
Start with a single backbone area 0. Give each switch a stable router ID, usually a loopback address such as 10.255.0.1, 10.255.0.2 and so on. Write the plan down before you touch any device.
Create loopbacks
Loopbacks never go down, which keeps the router ID and management address stable.
interface loopback 0 ip address 10.255.0.1 255.255.255.255
Configure point-to-point links
Use a small subnet per link and set the OSPF network type to point-to-point, which avoids DR/BDR elections and speeds up convergence.
interface vlan 900 ip address 10.0.0.1 255.255.255.254 ip ospf network point-to-point
Enable OSPF and advertise networks
Advertise the loopback, the transit links and the user VLANs that should be reachable.
router ospf 1 router-id 10.255.0.1 network 10.255.0.1 0.0.0.0 area 0 network 10.0.0.0 0.0.0.1 area 0 network 10.10.0.0 0.0.255.255 area 0 passive-interface default no passive-interface vlan 900
Make user VLANs passive
Passive interfaces are advertised but never form neighbours, so a laptop on a user VLAN cannot inject routes. 'passive-interface default' with exceptions for transit links is the safest pattern.
Authenticate neighbours
Use message-digest or SHA authentication so rogue devices cannot join OSPF.
interface vlan 900 ip ospf authentication message-digest ip ospf message-digest-key 1 md5 <strong-key>
Originate a default route
On the switch that connects to the firewall, inject a default route into OSPF.
router ospf 1 default-information originate
Verify neighbours and routes
Every neighbour should reach the FULL state, and remote subnets should show as O routes.
show ip ospf neighbor show ip route ospf
Test failover
Shut one link in a maintenance window and confirm traffic moves to the alternate path within seconds. Bring it back and confirm routes return.
Commands are generic, industry-standard examples. Exact syntax and menu names vary by model and firmware; check your device's manual on the Documentation page.
Pro tips
- Keep MTU identical on both ends of every OSPF link, or neighbours get stuck in EXSTART.
- Use reference bandwidth of 100G or more so 10G and 100G links get sensible costs.
- Document costs if you want traffic to prefer a specific path.
FAQ
Frequently asked questions
Static routes or OSPF?
Use static routes for very small networks. Use OSPF when you have multiple Layer 3 devices or redundant paths.
Why is my OSPF neighbour stuck?
Common causes are mismatched MTU, area ID, authentication, subnet mask or hello/dead timers.
Keep learning
Related guides
Inter-VLAN routing
Read more →Data center & core switching
Read more →How to Configure VLANs on a Managed Switch
Separate staff, guests, voice and cameras into their own VLANs: create VLANs, set access and trunk ports, and verify traffic separation.
Read more →How to Set Up Inter-VLAN Routing on a Layer 3 Switch
Route between VLANs at wire speed using switch virtual interfaces (SVIs), a DHCP relay and ACLs that control which networks can talk.
Read more →How to Configure Link Aggregation (LACP) Between Switches
Bundle two or more links into one logical link for more bandwidth and redundancy using IEEE 802.3ad LACP.
Read more →Stuck on a step?
Ask Navijin technical support or an authorised partner for help with your configuration.