In the early days of TCP/IP Networking, there was RIP. Now at the time RIP was the perfect Protocol for small private Networks; it was easy to configure and simple to understand. RIP became the go-to Internal Routing Protocol for a long time, but as networking technology evolved, the network designs evolved with them. Engineers now ran a range of technologies within their Networks, redundancy and resiliency became ever more important as the reliance on Internet grew, and the Routed Autonomous-Systems themselves grew larger and larger. RIP was never designed to scale, and scaling RIP often led to routing loop issues and terrible convergence times. A new standard was needed...
Enter OSPF! Developed by the IETF and published under the public RFC process, OSPF was designed for pure scalability and future proofing. With the ability to segregate sections of a network into individual routing domains, OSPF touted high-performance convergence on both small and large networks.
OSPF uses a hierarchy of logical "areas" to acheive this. Similar to the early ARPANET Internet, OSPF uses a backbone "Area 0" to secure the core network routing, and all other areas will branch off the Area 0. Routing Convergence is limited within the constraints of the area, and so update traffic can be minimized and isloated. Each area must have a "Designated Router" and a "Backup Designated Router", or rather a DR and BDR. These are devices that have interfaces in both the local area, and the backbone area, and are responsible for sharing route updates between the two. An area-wide DR election is held whenever a new OSPF-speaker joins an area. OSPF will elect the router with the highest DR Priority (default value of 1) to act as DR, and will elect the highest OSPF Router-ID (RID) in a tie scenario. Once the initial election has been completed, all other OSPF Routers (DROTHERs) will advertise their routing tables to the DR over multicast address 220.127.116.11. The DR will collect a full routing topology (Link-State Database) of the local area, and then share with all DROTHERs on the DR multicast address 18.104.22.168. Once each router hold an identical copy of the Link-State Database, they will begin to calculate their own best paths using the SPF Algorithm.
The SPF Algorithm
The Shortest-Path Algorithm is what OSPF uses to calculate the best path to a given address. The SPF Algorthm is based closely on the famous Dutch programmer Edsger Dijkstra's algorthm, which is in fact used in most modern GPS systems in a similar manner for calculating the shortest path to a geographical destination. Each router will use their copy of the Link-State Database as the input to the algorithm.
The SPF Algorithm will compare the total combines "costs" of each link along the path to a known destination. The costs are as follows:
Default Cost Media 64 T1/Serial 10 Ethernet (10Mbps) 1 Fast Ethernet (100Mbps) 1 Gigabit Ethernet (1Gbps) 1 Ten-Gigabit Ethernet (10Gbps)
Being an old protocol, 100Mbps Ethernet was the most advanced media at the time, as is such used as the reference bandwidth. Any current OSPF network should use the
auto-cost reference-bandwidth command to adjust this reference point to the highest possible media within the Network.
The path with the lowest total cost to a destination is selected as the Best Path, and installs this path in the Routing Table. Whenever a new route within an area is advertised, the DR will propgate an updated Link-State Database to all DROTHERs. The SPF calculation is then performed again by every routerfor the new Link-State Database.
OSPF design plays a much larger part in the implementation within a Network than the configuration necessarily does. It is important to plan carefully how many areas you wish to create, which devices will act as the DR and BDR for each areas, and what networks you will want advertising. If a particular area has no alternate path to Inter-area networks, it may be best to configure as a Stub Area with a default route to the Area 0. If you are advertising successive subnets, it may be worth summarising the CIDR ranges to other areas, to minimize routing table sizes. All in all, OSPF does require more pre-planning than other protocols before setting-up, but OSPF is so highly configurable that is can scale to any network,
Now, to enable a basic OSPF configuration. First, we will configure a couple of interfaces...
Router 1(config)#interface GigabitEthernet 0/0 Router 1(config-if)#description Link to R2 Router 1(config-if)#ip address 10.0.0.1 255.255.255.252 Router 1(config-if)#no shutdown Router 1(config-if)#interface GigabitEthernet 1/0 Router 1(config-if)#description Link to R3 Router 1(config-if)#ip address 10.0.0.5 255.255.255.252
Next, let us enable our OSPF process. The Autonomous System is a local identifier, and will not affect adjacencies like in EIGRP. We will also set a manual RID, although OSPF will select one if not specified based on the highest loopback IP address, or else the highest interface IP address:
Router 1(config)#router ospf 1 Router 1(config-router)#router-id 22.214.171.124
Now we need to define which networks will be advertised into OSPF, and which area they are in. This can be done by using the following commands:
Router 1(config-router)#network 10.0.0.0 0.0.0.3 area 0 Router 1(config-router)#network 10.0.0.4 0.0.0.3 Router 1(config-router)#redistribute connected subnets
It is important to understand that the OSPF Network command does not directly advertise the specified network, but instead is used to identify participating interfaces. An interface with 192.168.1.1/24 can be advertised into OSPF using a
network 192.168.1.0 0.0.0.255 command, but also with a
network 192.168.1.1 0.0.0.0 or even
network 0.0.0.0 0.0.0.0. As long as the network and wildcard mask in the network command can capture the IP address of a single interface, that interface will become OSPF-active and will advertise the full Network prefix in which it's interface address resides.
network 0.0.0.0 0.0.0.0 will enable OSPF on all interfaces and advertise all local networks, however this is poor practise and can often lead to major problems down the line.
If we configure routers R2 and R3 similarly, we should see the OSPF adjacenies form. We can verify with the
show ip ospf neighbor command:
Router1# show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface 126.96.36.199 1 FULL/BDR 00:00:30 10.0.0.2 GigabitEthernet0/0 188.8.131.52 1 FULL/DR 00:00:30 10.0.0.6 GigabitEthernet1/0
All three routers are in the same area (Area 0), and we can see that the DR election has taken place. With no manual DR Priorities configured, we can see that OSPF has failed over to looback addresses to decide the election. Neighbor 184.108.40.206 (R3) has been elected DR, with R2 as the backup.
Now R4 has just been added to the network, a gateway router for a small branch of the network. We will connect R4 directly to R1:
Router 1(config)#interface GigabitEthernet 1/1 Router 1(config-if)#description Link to R4 Router 1(config-if)#ip address 10.0.0.9 255.255.255.252 Router 1(config-if)#no shutdown
Being a small distribution router, we don't want R4 joining our backbone area, so we will create Area 1. Because R4's only path to the network is via R1, there is no use in sharing all routes with R4. By configuring Area 1 as a stub, R1 will know not to converge with R4 and will instead simply inject a default route (0.0.0.0/0) into R4's Routing Table:
Router 1(config)#router ospf 1 Router 1(config-router)#network 10.0.0.8 0.0.0.3 area 1 Router 1(config-router)#area 1 stub Router 4(config)#router ospf 4 Router 4(config-router)#network 10.0.0.8 0.0.0.3 area 0 Router 4(config-router)#network 192.168.1.0 0.0.0.255 area 1 Router 4(config-router)#area 1 stub
Here I have outlined a basic OSPF network configuration. It is important to understand that OSPF is a highly tunable, maleable Routing Protocol, and it can be configured to do almost anything you would need it for. I hope to go into some of the more advanced OSPF concepts, such as LSA types, Stub Area types and redistribution in a future post, but hopefully this has given a good insight into the world of OSPF.