Implementing OSPF as an Underlay Protocol in SONiC
As data center networks continue to evolve, the choice of underlay routing protocol becomes increasingly important. While BGP has gained popularity in modern data center designs, many organizations still prefer using OSPF as their underlay protocol due to its familiarity and widespread deployment in enterprise networks. In this article, I’ll explore how to implement OSPF as an underlay protocol in Enterprise SONiC, covering key configuration aspects, design considerations, and best practices.
Why OSPF as an Underlay?
Before diving into the implementation details, let’s understand why you might choose OSPF as your underlay protocol:
OSPF Design Principles in SONiC
Enterprise SONiC’s implementation of OSPF as an underlay follows these key design principles:
Configuring IP Unnumbered
One of the most elegant aspects of modern data center designs is the use of IP unnumbered interfaces. This approach allows an interface to “borrow” its IP address from another interface (typically a loopback), saving IP addresses and simplifying configuration.
Here’s how to configure IP unnumbered in SONiC:
ip unnumbered <donor-interface>
For example:
Leaf1(config)# interface Ethernet 14
Leaf1(conf-if-Ethernet14)# ip unnumbered Loopback 0
You can verify the configuration with:
show ip interfaces
Basic OSPF Configuration
To configure OSPF in SONiC, you start by enabling the OSPF router process and assigning a router ID:
router ospf [vrf <vrf-name>]
ospf router-id <routerid>
Then, you enable OSPF on specific interfaces by assigning them to an area:
ip ospf area <area-id>
Here’s a complete example:
Leaf1(config)# router ospf
Leaf1(config-router-ospf)# ospf router-id 99.1.1.1
Leaf1(config-router-ospf)# exit
Leaf1(config)# interface Ethernet 14
Leaf1(conf-if-Ethernet14)# ip ospf area 0
Leaf1(conf-if-Ethernet14)# ip ospf network point-to-point
To verify your configuration, use:
show ip ospf
show ip ospf interface
OSPF Reference Bandwidth
By default, OSPF calculates link cost using the formula: Cost = Reference BW/Link BW (in Mbps), with a default reference bandwidth of 10^8 (100 Mbps). This means that all links faster than 100 Mbps (like 1G, 10G, etc.) would get the same minimum cost of 1, making them indistinguishable from a routing perspective.
To properly account for modern high-speed data center links, you should adjust the reference bandwidth:
auto-cost reference-bandwidth <ref-bandwidth>
For example:
Leaf1(config)# router ospf
Leaf1(config-router-ospf)# auto-cost reference-bandwidth 100000
This sets the reference bandwidth to 100 Gbps, allowing OSPF to differentiate between links of various speeds up to 100G.
Recommended by LinkedIn
You can verify this configuration with:
Leaf1# show running-configuration ospf
!
router ospf
ospf router-id 99.1.1.1
auto-cost reference-bandwidth 100000
OSPF Authentication
Security is crucial in data center networks. SONiC supports three authentication options for OSPF:
To configure message digest authentication:
router ospf
area <areaid> authentication message-digest
ip ospf authentication message-digest
ip ospf message-digest-key <keyid> md5 <md5key>
Here’s a complete example:
Leaf1(config)# router ospf
Leaf1(config-router-ospf)# area 0 authentication message-digest
Leaf1(config-router-ospf)# exit
Leaf1(config)# interface Ethernet 14
Leaf1(conf-if-Ethernet14)# ip ospf authentication message-digest
Leaf1(conf-if-Ethernet14)# ip ospf message-digest-key 1 md5 Bro@dcom
This configuration ensures that OSPF adjacencies are only formed between switches that share the same authentication credentials, protecting your network from unauthorized devices.
A Complete OSPF Underlay Example
Let’s look at a more comprehensive configuration example for a leaf switch in an OSPF underlay:
interface Loopback 0
description Router-ID
ip address 192.168.0.1/32
ip ospf area 0.0.0.1
interface Ethernet7
mtu 9100
speed 25000
fec none
no shutdown
ip unnumbered Loopback0
ip ospf area 0.0.0.1
ip ospf authentication message-digest
ip ospf bfd
ip ospf network point-to-point
ip ospf message-digest-key 1 md5 08d542e925e9fed7fe3c5eb3f6c2a5bb encrypted
interface Ethernet8
mtu 9100
speed 25000
fec none
no shutdown
ip unnumbered Loopback0
ip ospf area 0.0.0.1
ip ospf authentication message-digest
ip ospf bfd
ip ospf network point-to-point
ip ospf message-digest-key 1 md5 08d542e925e9fed7fe3c5eb3f6c2a5bb encrypted
router ospf
ospf router-id 192.168.0.1
auto-cost reference-bandwidth 100000
log-adjacency-changes detail
area 0.0.0.1 authentication message-digest
This configuration includes: - A loopback interface for the router ID - Two Ethernet interfaces configured with IP unnumbered - OSPF enabled on all interfaces with authentication - BFD for fast failure detection - Point-to-point network type for optimal operation - Adjusted reference bandwidth for proper cost calculation
Best Practices for OSPF Underlay
Based on the Enterprise SONiC documentation, here are some best practices to follow when implementing OSPF as your underlay protocol:
Integrating OSPF Underlay with BGP EVPN Overlay
When using OSPF as your underlay protocol with a BGP EVPN overlay, you’ll typically configure iBGP sessions between leaf and spine switches for the overlay. The OSPF underlay provides reachability for the BGP sessions.
Here’s a simplified example of how this integration works:
router ospf
ospf router-id 192.168.0.1
auto-cost reference-bandwidth 100000
area 0.0.0.1 authentication message-digest
router bgp 65000
router-id 192.168.0.1
address-family l2vpn evpn
advertise-all-vni
neighbor 192.168.0.4
remote-as 65000
update-source interface Loopback 0
address-family l2vpn evpn
activate
In this configuration, OSPF provides the underlay connectivity between the loopback interfaces, allowing the BGP sessions to establish over these loopbacks.
Conclusion
Implementing OSPF as an underlay protocol in Enterprise SONiC provides a familiar and effective foundation for your data center network. The combination of IP unnumbered, authentication, and BFD creates a robust, secure, and fast-converging underlay that can support advanced overlay technologies like VXLAN and EVPN.
While BGP has become increasingly popular for data center underlays, OSPF remains a viable and sometimes preferable option, especially for organizations with existing OSPF expertise or those seeking a clear separation between underlay and overlay routing protocols.
By following the configuration examples and best practices outlined in this article, you can successfully deploy an OSPF underlay in your Enterprise SONiC network, providing the reliable connectivity foundation needed for modern data center applications.