Open Shortest Path First (OSPF) is a link-state routing protocol used to find the best path between the source and the destination router using its own Shortest Path First.
The OSPF stands for Open Shortest Path First. It is a widely used and supported routing protocol. OSPF is an intradomain protocol, which is used within an area or a network. It is an interior gateway protocol designed within a single autonomous system. It is based on a link-state routing algorithm in which each router contains the information of every domain, and based on this information, it determines the shortest path. The goal of routing is to learn routes.
- OSPF is an open standards routing protocol
- This works by using the Dijkstra algorithm
- OSPF provides the following features:
- Minimizes routing update traffic
- Allows scalability (e.g. RIP is limited to 15 hops)
- Has unlimited hop count
- Supports VLSM/CIDR
- Allows multi-vendor deployment (open standard)
- AD -100
- Hop count is unlimited
- Metric = Cost – 108/BW
- Classless, VLSM
- Load balance up to SIX routers
- Require more processing power
OSPF Hello
- When router A starts it sends a Hello packet – uses 224.0.0.5
- Hello packets are received by all neighbors
- B will write A’s name on its neighbor’s table
- C also processes the same way
“Hello” Packets
- Small frequently-issued packets
- Discover neighbors and negotiate “adjacencies”
- Verify continued availability of adjacent neighbors
- Hello packets and Link State Advertisements (LSAs) build and maintain the topological database
- Hello, packets are addressed to 224.0.0.5.
How does OSPF work?
There are three steps that can explain the working of OSPF:
Step 1: The first step is to become OSPF neighbors. The two connecting routers running OSPF on the same link create a neighbor relationship.
Step 2: The second step is to exchange database information. After becoming neighbors, the two routers exchange the LSDB information with each other.
Step 3: The third step is to choose the best route. Once the LSDB information has been exchanged with each other, the router chooses the best route to be added to a routing table based on the calculation of SPF.
Types of links in OSPF
A link is basically a connection, so the connection between two routers is known as a link.
There are four types of links in OSPF:
- Point-to-point link: The point-to-point link directly connects the two routers without any host or router in between.
- Transient link: When several routers are attached in a network, they are known as a transient link.
The transient link has two different implementations:
Unrealistic topology: When all the routers are connected to each other, it is known as an unrealistic topology.
Realistic topology: When some designated router exists in a network then it is known as a realistic topology. Here designated router is a router to which all the routers are connected. The routers will pass all the packets sent through the designated router. - Stub link: It is a network that is connected to a single router. Data centers the network through a single router and leaves the network through the same router.
- Virtual link: If the link between the two routers is broken, the administration creates the virtual path between the routers, and that path could be a long one also.
OSPF Terms:
1. Link:
- A network or router interface assigned to a given network
- Link (interface) will have “state” information associated with it
- Status (up or down)
- IP Address
- Network type (e.g. Fast Ethernet)
- Bandwidth
- Addresses of other routers attached to this interface
2. Router ID:
- The Router ID (RID) is an IP address used to identify the router
- Cisco chooses the Router ID by using the highest IP address of all configured loopback interfaces
- If no loopback interfaces are configured with addresses, OSPF will choose the highest IP address of all active physical interfaces.
- You can manually assign the router ID.
- The RID interface MUST always be up, therefore loopbacks are preferred
3. Neighbours:
- Neighbors are two or more routers that have an interface on a common network
- E.g. two routers connected on a serial link
- E.g. several routers connected on a common Ethernet or Frame relay network
- Communication takes place between/among neighbors
- Neighbors form “adjacencies”
4. Adjacency:
- A relationship between two routers that permits the direct exchange of route updates
- Not all neighbors will form adjacencies
- This is done for reasons of efficiency – more later
5. OSPF Areas:
- An OSPF area is a grouping of contiguous networks and routers
- Share a common area ID
- A router can be a member of more than one area (area border router)
- All routers in the same area have the same topology database
- When multiple areas exist, there must always be an area 0 (the backbone) to which other areas connect
OSPF Basic Configuration
1 | Enter global configuration mode. | router#configure terminal |
2 | Create an OSPF routing process and enter router configuration mode. | router(config)#router ospf process-id |
3 | Configure the interfaces that OSPF will be enabled on. | router(config-router)#network network wildcard-mask area area-id |
Another thing that is often overlooked when configuring routing protocols is the inclusion of interfaces into a routing protocol process without sending advertisements out of the interface. On most networks, segments exist that contain a number of hosts but do not include any other routing protocol devices; in these situations, it is not necessary to send routing protocol traffic out of the interface as it is not required and can be used by malicious users to map out the internals of the network. In these situations it is best to configure these interfaces as passive; this label will disable routing protocol advertisements from exiting the interface.
OSPF passive-interface Configuration
1 | Enter global configuration mode. | router#configure terminal |
2 | Enter EIGRP router configuration mode. | router(config)#router ospf process-id |
3 | Configure an interface as passive.The default parameter can be used to change the default behavior so that all interfaces are passive by default. In this situation, an interface is configured as not passive with the no passive-interface interface-type interface-number command. | router(config-router)#passive-interface [default]interface-type interface-number |
OSPF Basic Configuration Examples
As discussed above, the basic configuration of OSPF is rather simple. A basic network is flat and includes all OSPF devices in a single area. Since OSPF must have a backbone area (Area 0), it makes sense to include all of the devices within this area. With the network, there are two different ways to configure the network command depending on the intentions of the design engineer. The first is to individually configure a network statement for each IP subnet; the configuration for this is shown in Table 3:
Table 3
OSPF Basic Configuration— Individual network statements
1 | Enter global configuration mode. | router#configure terminal |
2 | Enter EIGRP router configuration mode. | router(config)#router ospf 10 |
3 | Configure a network statement for the F0/0 interface. | router(config-router)#network 172.16.100.0 0.0.1.255 area 0 |
4 | Configure a network statement for the F0/1 interface. | router(config-router)#network 172.16.50.128 0.0.0.127 area 0 |
5 | Configure a network statement for the F0/2 interface. | router(config-router)#network 172.16.1.0 0.0.0.255 area 0 |
The other method that is commonly seen is to include all networks on a device into a single network statement. This can be done when there are multiple interfaces on a device that can be included in a single statement. For the topology, all of the networks can be included in a single network statement as shown in Table 4:
Table 4
OSPF Basic Configuration— Single network statement
1 | Enter global configuration mode | router#configure terminal |
2 | Enter EIGRP router configuration mode | router(config)#router ospf 10 |
3 | Configure a network statement for the F0/0 interface | router(config-router)#network 172.16.0.0 0.0.255.255 area 0 |
Keep in mind that the OSPF network statement only includes the interfaces on the configured device that match the network/wildcard mask pair; it does not advertise via OSPF that this device knows all routes to the whole 172.16.0.0/16 network, only the networks that match the network statement on this specific device. What this effectively means is that both configurations end up with the exact same OSPF function; the selection of one over the other is simply a matter of engineer preference.