Open Shortest Path First (OSPF) is a routing protocol developed by Internet Engineering Task Force (IETF).
OSPF is standards-based which means it is available on routers by Cisco as well as other vendors, making it a vendor-neutral routing protocol.
This is in contrast to Enhanced Interior Gateway Protocol (EIGRP) that is Cisco proprietary, and hence available only on Cisco routers.
OSPF divides its routing domain into smaller sub-divisions called areas. These OSPF areas are numbered and each may have several OSPF routers in it.
OSPF area 0 is at the center of an OSPF domain and all other areas are connected to it. It is basically a star topology of OSPF areas, area 0 being at the center of the star.
The advantage of OSPF areas is that most of the routing information is contained within an area and only summarized routing information is sent to routers in other areas.
This makes OSPF very efficient in terms of usage of resources like processing power, memory, and bandwidth. The conservative resource usage in turn enables OSPF to scale well to very large topologies.
Let’s start configuring our simple OSPF topology with a single area 0 in autonomous system (AS) 10 as shown in Figure 1.
We will not go into the details of IP address configuration and assume that all IP addresses have been pre-configured on all interfaces including the Loopback interfaces as shown in the figure.
Figure 1 Configuring OSPF
The router ospf command entered in global configuration mode with autonomous-system-number argument creates an OSPF routing instance. It is the first step in configuring OSPF on a router as done here on R1:
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#router ospf 10
As you may have noticed, we moved from global configuration mode to router configuration mode as indicated by changed router prompt.
The next step in configuring OSPF is to specify which router interfaces are included in OSPF using the network command, also mentioning OSPF area the interface belongs to.
The router would send OSPF messages and try to establish adjacencies with other OSPF speaking routers off these interfaces. We will enable OSPF on Fa0/0 and S0/0 on R1, placing both interfaces in area 0:
R1(config-router)#network 172.16.13.0 0.0.0.255 area 0
R1(config-router)#network 192.168.12.0 0.0.0.3 area 0
And that completes our OSPF configuration on R1. We would proceed with configuring OSPF on R2 and R3 following the same pattern, also enabling OSPF on Loopback0 interfaces:
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#router ospf 10
R2(config-router)#network 192.168.12.0 0.0.0.3 area 0
R2(config-router)#network 10.10.2.0 0.0.0.255 area 0
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#router ospf 10
R3(config-router)#network 172.16.13.0 0.0.0.255 area 0
R3(config-router)#network 10.10.3.0 0.0.0.255 area 0
That completes our OSPF configuration on R1, R2, and R3 and its time to verify if our configuration works as expected. If we configured OSPF correctly R1 should have established OSPF adjacencies with both R2 and R3. Let’s see if that’s the case:
R1#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
10.10.2.2 0 FULL/ – 00:00:35 192.168.12.2 Serial0/0
10.10.3.3 1 FULL/BDR 00:00:32 172.16.13.3 FastEthernet0/0
You can see two neighbors 10.10.2.2 and 10.10.3.3 which happen to be Loopback0 IP addresses of R2 and R3 respectively. More precisely, 10.10.2.2 and 10.10.3.3 are router IDs of R2 and R3 respectively, as an OSPF router chooses the highest IP address on a Loopback interface as its OSPF router ID by default (which influences also the election of DR and BDR devices).
The output shows R1 has successfully established adjacencies with both R2 and R3. We can probably hope that some routing information exchange may also have taken place by now, populating the routing table with some routes.
R2#show ip route
<Some output omitted for brevity>
Gateway of last resort is not set
192.168.12.0/30 is subnetted, 1 subnets
C 192.168.12.0 is directly connected, Serial0/0
172.16.0.0/24 is subnetted, 1 subnets
O 172.16.13.0 [110/74] via 192.168.12.1, 00:11:27, Serial0/0
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O 10.10.3.3/32 [110/75] via 192.168.12.1, 00:10:27, Serial0/0
C 10.10.2.0/24 is directly connected, Loopback0
R2 knows about 10.10.3.3/32 network, and observant readers may have noticed the /32 mask. Please refer to Figure 1 and note that we configured our Loopback0 interfaces with /24 mask.
This apparent anomaly is the default behavior of OSPF, advertising Loopback interfaces with /32 masks. Let’s now seal the deal by pinging Loopback0 of R3 from R2 confirming end-to-end connectivity.
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.3.3, timeout is 2 seconds:
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/55/136 ms
When you implement this topology in a lab, you should use the show commands seen in this article on all your routers, closely examining the output. This would be fun and a great way to get to know OSPF better.
Further Details and Guide about OSPF
One of the most popular dynamic routing protocols available is the Open Shortest Path First (OSPF). This is a link-state algorithm protocol (compared with distance-vector protocols like RIP) and is categorized as an Interior Gateway Protocol (IGP) like EIGRP, IS-IS etc.
Note that for very small networks you can achieve full routing connectivity by just configuring static routes without a dynamic routing protocol.
IGP protocols are running within the same Autonomous System network (i.e a network under the same administration domain, such as a company’s LAN network, a university’s campus network, a corporation’s private WAN network etc).
The strength of the OSPF is that it is a hierarchical protocol using network areas. Routing information distribution becomes more structured and also simpler to troubleshoot.
OSPF is extensively used in Cisco networks and is fully supported by the Cisco IOS operating system as we have seen above.
However, OSPF is also fully supported by other networking vendors such as Juniper etc.
The first step done by the OSPF is to establish communications with the neighboring routers. The aim is to obtain all possible network devices and links information by the neighboring routers so as to build a complete picture of the whole network topology.
Similarly, the neighboring routers will also receive information from other routers acting as neighbors. So that eventually all existing information in a network can be learned by all existing routers in the network (a topology table is built).
The event of routers establishing full communication with their neighbors (adjacency) is often referred to as Convergence.
After all routers establish communication with their neighbors (neighbor adjacency – Convergence), then the routing information exchange process takes place with the help of some special packets that are in charge of carrying routing information.
These packets are often referred to as Link State Advertisements (LSA packets). Apart from the hello packets, the OSPF routing protocol is also dependent on the LSA packets to work properly.
The algorithm used by OSPF to determine the shortest path to a specific destination is called Shortest Path First (SPF) and is very effective. Although stretching many paths to a specific destination, OSPF can determine which path is best with great precision.
But there is another advantage to OSPF, namely the concept of a hierarchical network that makes the process of updating routing information more efficient.
In applying the concept of this hierarchy, OSPF uses network areas as a collection of routers and links within which routing information is distributed.
What’s the concept of “Areas” in OSPF:
OSPF is created and designed to serve large-scale private networks. This means that OSPF must have a mechanism for high scalability, not easily exhausted or “stuck” because the network is increasingly enlarged.
In order for OSPF to be able to serve rapidly growing networks, the routing protocol is equipped with a hierarchical system in the form of grouping OSPF routers in an “Area”.
By dividing up the routers in the network into “Areas”, it will have many advantages, particularly to address the problem when the number of network routes is getting bigger and troubleshooting becomes more difficult. For this purpose the concept of an area is used to create a hierarchy.
Why splitting the network into Areas will help:
When a network keeps growing bigger and bigger, OSPF routing protocol is no longer effective if carried within a single area only.
As you already know, OSPF is a Link State protocol. That is, the routing protocol will collect data for the status of each link in the OSPF network.
What will happen if the OSPF network consists of hundreds or even thousands of links? Of course the process of collecting and updating all link information will take some time and a lot of processor resources.
After that, the process of determining the best path for all destination networks by a specific OSPF process running on a router will become very slow.
Based on this limitation, the concept of Areas will help a lot. Now routers within an area are only responsible to monitor the status of links within that specific area only.
The aim is to reduce the number of links that are monitored in order to distribute routing information as quickly and efficiently as possible, thus enhancing network stability.
How Link State Information is distributed
OSPF uses Link State Advertisements (LSA) to distribute link state information between the routers in the OSPF topology.
In disseminating this information, the LSA mechanism uses special packets (LSA packets) that carry information in the form of link status – the status of an existing link in a router.
This packet can then be spread to the entire OSPF network. All information contained in the router links and collected by the OSPF process, is then wrapped within LSA packets and then sent to the entire OSPF network.
What is an LSA Packet
As explained above, LSA packets contain information about the links that exist on a router and the status of each link (such information contain link bandwidth as well). LSA packets are then propagated to other routers from each router to its neighbor.
LSA packet exchange is not happening just at the beginning of the formation of the OSPF topology database, but there are continuous link status updates in the OSPF network.
However, the LSA packets propagated at the first time are different from the subsequent packet distributions.
Because the first LSA packet contains the most complete information about the status of the links in the network, while the next LSA packets are just updated information of the link status, thus less bandwidth is consumed by the update LSA packets.
LSA packets are also divided into several types. This division is made based on the information contained in each packet and for whom the LSA packet is intended.
OSPF LSA packets are divided into seven types. Each type has its usefulness in transferring Link State information.
OSPF Router Types:
As we already said, OSPF uses the concept of areas to ensure proper routing information distribution and equipment stability. Based on the location and role that a router has within an OSPF area, the router can be categorized into different OSPF router types.
The location of a router within an OSPF network also affects its function. Below are some types of OSPF routers based on their location and their function within the OSPF network:
* Internal Router
Routers that are classified as internal are those that are connected inside an OSPF area. Routers in the same area will perceive all other routers in that area as internal routers.
An internal router has no connections with other areas, so that its function is only to give and receive routing information regarding its area only.
The Internal Router’s task is to maintain a topology database and routing table that is accurate for every subnet in its area. This type of router does LSA flooding only to other routers that are considered as internal router (within the same are).
* Backbone Router
One of the rules that must be followed in OSPF networks is that if there are more than one network Areas, these must be connected to an area that is considered as the backbone area.
Backbone area is usually marked by numbering 0.0.0.0 or often referred to as Area 0. Routers that are entirely within the Area 0 backbone are named as backbone routers.
A Backbone router has knowledge of all the topology and routing information contained in the whole OSPF network.
* Area Border Router (ABR)
As the name implies, an “Area Border” router acts as a liaison between network Areas. This router connects together different Areas in the OSPF network.
However, because all areas must be connected to the backbone Area, this means that the ABR router is just connecting Area 0 with other areas.
So, ABR routers have connections to two distinct areas, one connection to Area 0 and another one to the other areas. ABR routers store and maintain information for every area connected with. Its job also is to disseminate routing information to each area.
However, the distribution of this information is done using a special LSA packet which is a summarization of the existing IP subnets in the network.
With this summary update the process of exchanging routing information between areas does not consume too much processing resources for the routers and also it does not take a lot of bandwidth.
* Autonomous System Boundary Router (ASBR)
An Autonomous System (AS) is a group of routers that form a network that is under one administrative domain (a single ownership).Usually all routers within the same AS are running the same routing protocol (e.g OSPF or RIP etc).
However, there are cases where a segment of the network is not possible to run the same routing protocol as the other routers. Maybe another IGP protocol is running.
Therefore a router must be configured to run both OSPF and another routing protocol (e.g RIP or EIGRP etc) for connecting the two segments. Such a router is called ASBR. ASBR routers can be placed anywhere in the network, but the router must have a leg in OSPF Area 0.
OSPF Area Types
After dividing the network into areas and configuring routers, each area can be categorized according to its characteristics in the network. We have the following OSPF Area types:
* Backbone Area
Backbone area is the area meeting place for all other areas in the OSPF network. This area is often marked with the number 0 or referred to as Area 0.
* Standard Area
Areas of this type are all the other areas besides Area 0. All routers that exist in this area will have the same link state information because they will form adjacencies with each other and exchange information directly. Thus, all routers that exist in this area will have the same topology database, but their routing tables may be different.
* Stub Area
Stub literally means the extreme end. This term is used in OSPF networks to dub one or more areas which are located at the end of the network with no other branches. Stub area is an area with no other paths to any other network except the backbone.
This Area does not receive LSA type 4 and 5 packets. That means this is an area of not receiving LSA packets from other areas delivered by the ABR router and not receiving LSA packets from other routing protocols that are outside of the ASBR router (LSA type 4 and 5).
So in other words, the routers in this area will only accept information from other routers in the same area, no new routing information from other routers. However, the next question is how this type of area can communicate with the outside world if there is no routing information that can be received from the outside world.
The answer is the default route. A default route exists in this area to send packets outside its boundaries via the default gateway router which is the router connecting the area with the backbone.
* Totally Stub Area
A Totally Stub area will never receive any routing information from the networks outside of its boundary. This area will block LSA type 3, 4, and 5 packets, so no information can get into this area. Areas of this type are also similar to stub areas, which rely on a default route to reach the outside world.
- Cisco OSPF DR-BDR Election in Broadcast Networks – Configuration Example
- How to Configure Port Forwarding on Cisco Router (With Examples)
- The Most Important Cisco Show Commands You Must Know (Cheat Sheet)
- Cisco Show IP Route Command (Routing Table)-Example and Explanation
- Configuring High Availability using HSRP and Boolean Object Tracking