Open Shortest Path First (OSPF) is a link-state routing protocol for IP networks. It uses a link state routing algorithm and falls into the group of interior routing protocols, operating within a single autonomous system (AS).
OSPF-speaking routers send Hello packets on all OSPF-enabled IP interfaces. If two routers sharing a common data link agree on certain parameters specified in their respective Hello packets, they become neighbors.
Adjacencies, which can be thought of as virtual point-to-point links, are formed between some neighbors. OSPF defines several network types and several router types. The establishment of an adjacency is determined by the types of routers exchanging Hellos and the type of network over which the Hello packets are exchanged.
Each router sends link-state advertisements (LSAs) over all adjacencies. The LSAs describe all of the router’s links, or interfaces, the router's neighbors, and the state of the links. These links might be to stub networks (those without another router attached), to other OSPF routers, to networks in other areas, or to external networks (those learned from another routing process). Because of the varying types of link-state information, OSPF defines multiple LSA types.
Each router receiving an LSA from a neighbor records the LSA in its link-state database and sends a copy of the LSA to all of its other neighbors. By flooding LSAs throughout an area, all routers will build identical link-state databases.
When the databases are complete, each router uses the SPF algorithm to calculate a loop-free graph describing the shortest (lowest cost) path to every known destination, with itself as the root.
When all link-state information has been flooded to all routers in an area, and neighbors have verified that their databases are identical, it means the link-state databases have been synchronized and the route tables have been built. Hello packets are exchanged between neighbors as keepalives, and LSAs are retransmitted. If the network topology is stable, no other activity should occur.For OSPF network design over NVIDIA L3 VMS, please refer to the Virtual Modular Switch Reference Guide.
The router ID is a 32-bit number assigned to the router running the OSPF protocol. This number uniquely identifies the router in the OSPF link-state database.
Router ID can be configured statically, however, if it is not configured, then the default election is as follows:
- If a loopback interface already exists, the router ID selects the highest loopback IP address assigned to a loopback interface. Effective tunnel IP is considered as loopback address.
- Otherwise, the the highest IP address assigned to any other interface on the system is selected as router ID.
Equal-cost multi-path (ECMP) routing is a routing strategy where next-hop packet forwarding to a single destination can occur over multiple paths. The OSPF link-state routing algorithm can find multiple routes to the same destination, all multiple routes are added to the routing table only if those routes are equal-cost routes.
In case there are several routes with different costs, only the route with the lowest cost is selected. In case there are multiple routes with the same lowest cost, all of them are used (up to maximum of 64 ECMP routes).
ECMP is not configurable but is enabled by default for OSPF.
The following configuration example refers to Router 2 in the figure above The remainder of the routers in the figure are configured similarly.
It is recommended to disable STP before enabling OSPF. Use the command “no spanning-tree”.
Enable IP routing functionality. Run:
switch (config)# ip routing
Enable the desired VLAN. Run:
switch (config)# vlan 10 switch (config)# vlan 20
Add this VLAN to the desired interface. Run:
switch (config)# interface ethernet 1/1 switch (config ethernet 1/1)# switchport access vlan 10 switch (config ethernet 1/1)# exit switch (config)# interface ethernet 1/2 switch (config ethernet 1/2)# switchport access vlan 20
Create a VLAN interface. Run:
switch (config)# interface vlan 10
Apply IP address to the VLAN interface. Run:
switch (config interface vlan 10)# ip address 10.10.10.2 /16
Enable the interface. Run:
switch (config interface vlan 10)# no shutdown
Create a second VLAN interface. Run:
switch (config)# interface vlan 20
Apply IP address to the second VLAN interface. Run:
switch (config interface vlan 20)# ip address 10.10.20.2 /16
Enable the second interface. Run:
switch (config interface vlan 20)# no shutdown
Basic OSPF Configuration:
Enable OSPF configuration commands. Run:
switch (config)# protocol ospf
Create an OSPF instance. Run:
switch (config)# router ospf
Only one instance of OSPF per VRF is supported.
Associate the VLAN interfaces to the OSPF area. Area 0 is the backbone area. Run:
switch (config interface vlan 10)# ip ospf area 0 switch (config interface vlan 10)# exit switch (config)# interface vlan 20 switch (config interface vlan 20)# ip ospf area 0
To verify OSPF configuration and status:
Verify OSPF configuration and status. Run:
switch (config) # show ip ospf Routing Process 1 with ID 10.10.10.10 vrf-default Stateful High Availability disabled Graceful-restart is not supported Supports only single TOS (TOS 0) route Opaque LSA not supported OSPF Admin State is enabled Redistributing External Routes: Disabled Administrative distance 110 Reference Bandwidth is 100Gb Initial SPF schedule delay 1 msecs SPF Hold time 10 msecs Maximum paths to destination 64 Router is not originating router LSA with maximum metric Condition: Always Number of external LSAs 0, checksum sum 0 Number of opaque AS LSAs 0,checksum sum 0 Number of areas is 1, 1 normal, 0 stub, 0 nssa Number of active areas is 1, 1 normal, 0 stub, 0 nssa Area (0.0.0.0) (Active) Interfaces in this area: 2 Active Interfaces: 2 Passive Interfaces: 0 SPF Calculation has run 5 times This area is Normal area Number of LSAs: 1, checksum sum 7700
Verify the OSPF neighbors status. Make sure that each neighbor reaches FULL state with its peer to enable it take part in all dynamic routing changes in the network. Run:
switch (config) # show ip ospf neighbors Neighbor 10.10.10.1, interface address 10.10.10.2 In the area 0.0.0.0 via interface Vlan 10 Neighbor priority is 1, State is FULL BDR is 10.10.10.1 Options 0 Dead timer due in 35 Neighbor 10.10.20.1, interface address 10.10.20.2 In the area 0.0.0.0 via interface Vlan 20 Neighbor priority is 1, State is FULL BDR is 10.10.20.1 Options 0 Dead timer due in 35
Verify the OSPF interface configuration and status. Run:
switch (config) # show ip ospf interface Interface Vlan is 10 Enabled, line protocol is Down IP address 10.10.10.2, Mask 255.255.0.0 [primary] Process ID 1 VRF Default, Area 0.0.0.0 OSPF Interface Admin State is enabled State DOWN, Network Type BROADCAST, Cost 1 Transmit delay 1 sec, Router Priority 1 No designated router on this network No backup designated router on this network Timer intervals (sec's): Hello 10, Dead 40, Wait 40, Retransmit 5 No authentication Number of opaque link LSAs: 0, checksum sum 0 Interface Vlan is 20 Enabled, line protocol is Up IP address 10.10.20.2, Mask 255.255.0.0 [primary] Process ID 1 VRF Default, Area 0.0.0.0 OSPF Interface Admin State is enabled State DESIGNATED ROUTER, Network Type BROADCAST, Cost 1 Transmit delay 1 sec, Router Priority 1 No designated router on this network No backup designated router on this network Timer intervals (sec's): Hello 10, Dead 40, Wait 40, Retransmit 5 No authentication Number of opaque link LSAs: 0, checksum sum 0
Additional Reading and Use Cases
For more information about this feature and its potential applications, please refer to the following community post: