Configure OSPF dynamic routing with FRRouting for enterprise network failover

Advanced 45 min Apr 03, 2026 17 views
Ubuntu 24.04 Ubuntu 22.04 Debian 12 AlmaLinux 9 Rocky Linux 9 Fedora 41

Set up Open Shortest Path First (OSPF) protocol using FRRouting for dynamic network routing, multi-area configurations, and automatic failover in enterprise environments.

Prerequisites

  • Root or sudo access
  • Multiple network interfaces
  • Basic understanding of IP routing
  • Network connectivity between routers

What this solves

OSPF (Open Shortest Path First) is a link-state routing protocol that automatically calculates the best routes through your network and provides fast convergence during network failures. This tutorial shows you how to configure OSPF using FRRouting for enterprise networks that need dynamic routing, load balancing across multiple paths, and automatic failover when links go down.

Step-by-step configuration

Update system packages

Start by updating your package manager to ensure you get the latest versions of all packages.

sudo apt update && sudo apt upgrade -y
sudo dnf update -y

Install FRRouting

FRRouting is a network routing software suite that implements OSPF, BGP, RIP, and other routing protocols. Install it along with required dependencies.

sudo apt install -y frr frr-pythontools
sudo dnf install -y frr frr-pythontools

Enable IP forwarding

Configure the kernel to forward packets between network interfaces, which is required for routing functionality.

echo 'net.ipv4.ip_forward=1' | sudo tee -a /etc/sysctl.conf
echo 'net.ipv6.conf.all.forwarding=1' | sudo tee -a /etc/sysctl.conf
sudo sysctl -p

Configure FRRouting daemons

Enable the OSPF daemon and configure which routing protocols FRRouting should run. This file controls which daemons start automatically.

bgpd=no
ospfd=yes
ospf6d=no
ripd=no
ripngd=no
isisd=no
pimd=no
ldpd=no
nhrpd=no
eighrpd=no
babeld=no
sharpd=no
pbrd=no
staticd=yes
vrrpd=no

Create basic OSPF configuration

Configure OSPF with a router ID, network advertisements, and basic area settings. Replace the IP addresses with your actual network ranges.

!
! FRR configuration for OSPF
!
frr version 8.1
frr defaults traditional
!
hostname router1
password zebra
enable password zebra
!
router ospf
 ospf router-id 10.0.0.1
 network 10.0.1.0/24 area 0
 network 10.0.2.0/24 area 0
 network 192.168.1.0/24 area 1
 area 0 authentication message-digest
 area 1 authentication message-digest
 passive-interface lo
!
interface eth0
 ip ospf message-digest-key 1 md5 ospf-secure-key-2024
!
interface eth1
 ip ospf message-digest-key 1 md5 ospf-secure-key-2024
!
line vty
!

Set proper file permissions

Configure correct ownership and permissions for FRRouting configuration files. The frr user needs read access, and the configuration should not be world-readable for security.

sudo chown frr:frr /etc/frr/frr.conf
sudo chmod 640 /etc/frr/frr.conf
sudo chown frr:frr /etc/frr/daemons
sudo chmod 644 /etc/frr/daemons
Never use chmod 777. It gives every user on the system full access to your routing configuration files, which could compromise network security. Use specific ownership and minimal permissions instead.

Start and enable FRRouting

Enable FRRouting to start automatically on boot and start the service immediately.

sudo systemctl enable frr
sudo systemctl start frr
sudo systemctl status frr

Configure multi-area OSPF topology

Set up a more complex OSPF configuration with multiple areas connected through the backbone area (Area 0). This example shows Area 1 and Area 2 connected through Area 0.

sudo vtysh -c "configure terminal" -c "router ospf" -c "area 1 range 192.168.1.0/24" -c "area 2 range 192.168.2.0/24" -c "area 0 range 10.0.0.0/16"

Configure OSPF interface parameters

Set OSPF-specific interface parameters including hello intervals, dead intervals, and cost values for optimal convergence and load balancing.

sudo vtysh << EOF
configure terminal
interface eth0
ip ospf hello-interval 10
ip ospf dead-interval 40
ip ospf cost 100
exit
interface eth1
ip ospf hello-interval 10
ip ospf dead-interval 40
ip ospf cost 200
exit
interface eth2
ip ospf hello-interval 10
ip ospf dead-interval 40
ip ospf cost 150
exit
EOF

Configure OSPF area authentication

Enable MD5 authentication for all OSPF areas to secure routing updates and prevent unauthorized routers from joining your network.

sudo vtysh << EOF
configure terminal
router ospf
area 0 authentication message-digest
area 1 authentication message-digest
area 2 authentication message-digest
exit
interface eth0
ip ospf message-digest-key 1 md5 production-ospf-key-2024
exit
interface eth1
ip ospf message-digest-key 1 md5 production-ospf-key-2024
exit
interface eth2
ip ospf message-digest-key 1 md5 production-ospf-key-2024
exit
EOF
Note: Use the same authentication key on all routers in the same area. Different areas can use different keys for additional security segmentation.

Configure OSPF stub areas

Configure stub areas to reduce LSA flooding and improve convergence times in areas that don't need full external routing information.

sudo vtysh << EOF
configure terminal
router ospf
area 1 stub
area 1 default-cost 100
area 2 stub no-summary
area 2 default-cost 150
exit
EOF

Save configuration permanently

Write the running configuration to startup configuration so changes persist after reboots.

sudo vtysh -c "write memory"

Configure OSPF monitoring and logging

Enable OSPF debugging

Configure detailed logging for OSPF events, adjacency changes, and LSA updates to help with troubleshooting and monitoring.

sudo vtysh << EOF
configure terminal
log file /var/log/frr/ospfd.log
log syslog
debug ospf event
debug ospf lsa
debug ospf zebra
exit
EOF

Configure log rotation

Set up log rotation to prevent OSPF logs from consuming too much disk space while maintaining historical data for troubleshooting.

/var/log/frr/*.log {
    daily
    missingok
    rotate 14
    compress
    delaycompress
    notifempty
    postrotate
        systemctl reload frr > /dev/null 2>&1 || true
    endscript
}

Implement OSPF failover scenarios

Configure equal-cost multipath routing

Enable ECMP to use multiple equal-cost paths simultaneously, providing both load balancing and automatic failover capability.

sudo vtysh << EOF
configure terminal
router ospf
maximum-paths 4
exit
EOF

Test link failover behavior

Simulate a network failure to verify OSPF converges properly and reroutes traffic through alternate paths.

sudo ip link set eth1 down
sudo vtysh -c "show ip ospf neighbor"
sudo vtysh -c "show ip route ospf"
sudo ip link set eth1 up

Configure BFD for fast convergence

Enable Bidirectional Forwarding Detection to detect link failures in milliseconds rather than seconds, dramatically improving failover times.

sudo vtysh << EOF
configure terminal
interface eth0
ip ospf bfd
exit
interface eth1
ip ospf bfd
exit
interface eth2
ip ospf bfd
exit
router ospf
ospf bfd
exit
EOF

Verify your setup

Check OSPF neighbor relationships, routing table, and network convergence to ensure proper operation.

sudo vtysh -c "show ip ospf neighbor"
sudo vtysh -c "show ip ospf database"
sudo vtysh -c "show ip route ospf"
sudo vtysh -c "show ip ospf interface"

Verify that neighbors are in "Full" state and check that routes are being learned properly:

sudo vtysh -c "show ip ospf neighbor detail"
sudo vtysh -c "show ip ospf border-routers"
ping 192.168.1.1
traceroute 192.168.2.1

Monitor OSPF convergence times and verify authentication is working:

sudo tail -f /var/log/frr/ospfd.log
sudo vtysh -c "show ip ospf database router"
sudo vtysh -c "show running-config" | grep -A 20 "router ospf"

Troubleshoot OSPF adjacencies and routing loops

Debug neighbor adjacency issues

Use OSPF debugging commands to identify why neighbors aren't forming adjacencies or why the network isn't converging properly.

sudo vtysh << EOF
enable
debug ospf adj
debug ospf hello
show ip ospf neighbor detail
show ip ospf interface
EOF

Identify and resolve routing loops

Check for routing loops and suboptimal paths by examining the OSPF topology database and routing calculations.

sudo vtysh -c "show ip ospf database network"
sudo vtysh -c "show ip ospf spf-tree"
sudo vtysh -c "show ip ospf route"
traceroute -n 192.168.2.1

Common issues

Symptom Cause Fix
Neighbors stuck in Init state Authentication mismatch or firewall blocking Check authentication keys and allow OSPF traffic (protocol 89)
No routes learned via OSPF Area configuration mismatch Verify network statements match interface subnets and area assignments
Slow convergence after link failure Default OSPF timers too conservative Reduce hello/dead intervals and enable BFD for sub-second detection
FRR service fails to start Configuration syntax error Check syntax with sudo vtysh -f /etc/frr/frr.conf --dry-run
High CPU usage during convergence Too many LSAs or frequent topology changes Implement stub areas and area summarization to reduce LSA flooding
Routes flapping between paths Equal cost paths with different metrics Adjust interface costs or implement route dampening

Next steps

Automated install script

Run this to automate the entire setup

#ospf #frrouting #dynamic-routing #network-failover #link-state-routing

Need help?

Don't want to manage this yourself?

We handle infrastructure for businesses that depend on uptime. From initial setup to ongoing operations.

Talk to an engineer