Open Shortest Path First (OSPF) v2 protocol is defined in RFC 2328 and based on link-state technology where a link is an interface on an L3 device such as a router. The state of the link is an attribute of that interface and its relationship to its neighbors. The interface attributes relevant to OSPF include the IP address, subnet mask, the type of the network, the routers that are also connected to that network, and what have you.
Unlike distance vector protocols that use Bellman-Ford, OSPF uses the shortest path first (or SPF or Dijkstra SPF) algorithm to determine the shortest to all known destination networks with the help of a graph.
When an OSPF router boots up, it generates a link-state advertisement (or LSA) for that router which represents the state of links. All routers exchange their LSAs via flooding mechanism. Once an exchange is completed, every router ends up with a database that is used to calculate the shortest path to each destination. Each OSPF router uses the Dijkstra SPF algorithm to derive the shortest path tree and the result of this calculation is stored in the routing table (or RIB). The algorithm places each router at the root of a tree and then calculates the shortest path to each destination network based on the cumulate cost needed to reach that destination.
EIGRP | OSPF | |
Best Path Selection Algorithm | DUAL FSM | Dijkstra SPF |
Administrative Distance | 90 | 110 |
Metric | Bandwidth, Load, Delay, and Reliability | Cost |
VLSM | Supported | Not Supported |
Authentication | Supported | Supported |
Multi Path | Supported | Supported (ECMP) |
Open Industry Standard | No | Yes, RFC 2328 |
OSPF uses interface cost as its metric, which is inversely proportional to the bandwidth of that interface, i.e. higher bandwidth means lower cost by default unless you modify it using ip ospf cost <value> command.
OSPF uses flooding to exchange link-state advertisements between routers and all routers within an area have an exact link-state database. Routers that have interfaces in multiple areas including backbone are known as Area Border Routers (ABRs). Routers that act as a gateway between OSPF and other routing protocols or other instances of the OSPF process are known as Autonomous System Border Routers (or ASBRs). OSPF finite state machine (or FSM) includes eight different states including down, attempt, init, two-way, exstart, exchange, loading, and full.
OSPF addresses three classes of network types, point to point (p2p), point to multipoint (p2mp), and broadcast.
Enabling OSPF on a Cisco router involves several steps.
The OSPF process ID is a numeric value only locally significant to the router, i.e. it is never sent to the other routers and thus doesn’t have to match with process IDs on other routers either. Technically, you can also run multiple OSPF processes on the same router too.
The network command is a way of assigning an interface to an area whereas a mask is used for ease of configuration so that you can put a bunch of interfaces into an area with one line. Area-id is the area number you want the interface to be in. It can be configured in a simple number format such as 0 or 1 or 2, and in the form of an IP address say 0.0.0.0 or 1.1.1.1.
RTA#
interface fa0/0
ip address 182.21.11.1 255.255.255.0
interface fa0/1
ip address 182.21.12.2 255.255.255.0
interface fa0/2
ip address 108.21.1.1 255.255.255.0
router ospf 101
network 182.21.0.0 0.0.255.255 area 0.0.0.0
network 108.21.1.1 0.0.0.0 area 2
Summarization is about consolidating multiple routes into one single advertisement. In OSPF, this is normally done at the ABRs. You can configure summarization between any two areas; however, it is recommended to summarize towards the backbone area so it can inject those summaries into other areas. Summarization is highly effective if the network addresses assigned are contiguous.
There are two types of summarization, i.e.
Inter-area route summarization is done on ABRs and applies to routes from within the AS, i.e. it doesn’t apply to routes coming into the OSPF domain from external sources. You can use area <area-id> range <address> <mask> command to configure inter-area summary. Here, area-id refers to the area containing networks that are to be summarized.
In this topology, RTB is summarizing the range of subnets from 108.21.64.0 to 18.21.95.0 into one range, i.e. 108.21.64.0 255.255.224.0 (/27) into the backbone area. Likewise, RTC is summarizing 108.21.96.0/27 into the backbone.
RTB#
router ospf 101
area 1 range 108.21.64.0 255.255.224.0
RTC#
router ospf 101
area 1 range 108.21.96.0 255.255.224.0
External routes summarization is relevant to external routes only, ones that are injected into OSPF via redistribution. Much like inter-area summarization, the address range being contiguous would make it straightforward.
You will need to use summary-address <ip-address> <mask> command on ASBR(s) doing the redistribution into OSPF. This command will not affect if configured on a router with no connection to another router outside the OSPF domain.
In the above topology, RTA and RTD are injecting external routes into OSPF. RTA is injecting subnets within the range of 108.21.64-95 and RTD is injecting subnets 108.21.96-127.
RTA#
router ospf 101
summary-address 108.21.64.0 255.255.224.0
redistribute bgp 50 metric 1000 subnets
RTD#
router ospf 101
summary-address 108.21.96.0 255.255.224.0
redistribute bgp 20 metric 1000 subnets
Unlike RIP or distance vector protocols, OSPF has built-in controls over route propagation. OSPF routes are allowed or denied into different OSPF areas based on the area type, such as backbone or stub areas. OSPF ABRs limit the advertisement of different types of routes into different OSPF areas depending on the type of associated LSA. For example, an OSPF ABR bordering an OSPF stub area would prevent the advertisement of external routes into the stub area. The ABR is a stub or totally-stub area that would advertise a default route as an inter-area route. However, an ABR to a totally-stub area prevents advertisements of any inter-area including any external routes into that area. One common use of route filtering is when performing mutual redistribution.
There are a couple of key concepts to understand about OSPF filtering.
Distribute-list in works on any OSPF router and would prevent routes from being added to the routing table but routes still get added to the LS database i.e. the downstream neighbors will still have those routes. However, distribute-list out works on an ASBR to filter redistributed routes into other protocols.
RTE#
interface fa0/1
ip address 213.25.15.130 255.255.255.192
interface fa0/0
ip address 213.25.15.2 255.255.255.192
router rip
network 213.25.15.0
RTC#
interface fa0/0
ip address 213.25.15.67 255.255.255.192
interface fa0/1
ip address 213.25.15.1 255.255.255.192
router ospf 101
redistribute rip metric 10 subnets
network 213.25.15.0 0.0.0.255 area 0
router rip
redistribute ospf 101 metric 2
passive-interface Ethernet0
network 213.25.15.0
RTA#
interface fa0/0
ip address 213.25.15.68 255.255.255.192
router ospf 101
redistribute rip metric 10 subnets
network 213.25.15.0 0.0.0.255 area 0
router rip
redistribute ospf 101 metric 1
network 213.25.15.0
If you were to do a “show ip route” on RTC, you would have found two paths to the 213.25.15.128 destination network. This occurred because RTC advertised the route to RTA via OSPF and RTA advertised it back via RIP. Now, to fix this issue, the most effective way would be to use a distribute-list on RTA to deny the 213.25.15.0 network from being put back into RIP.
RTA#
interface fa0/0
ip address 213.25.15.68 255.255.255.192
router ospf 101
redistribute rip metric 10 subnets
network 213.25.15.0 0.0.0.255 area 0
router rip
redistribute ospf 101 metric 1
network 213.25.15.0
distribute-list 1 out ospf 101
Open Shortest Path First (OSPF) v3 protocol is defined in RFC 5340 which defines the modifications to OSPFv2 to support IPv6. The fundamental ways the OSPF operates, such as flooding, DR election process, area support, SPF computations, NSSAs, and what have you, remain unchanged.
The OSPFv3 includes the following changes to support IPv6 protocol.
BGP is an exterior gateway protocol (or EGP) so it was created from ground up to perform interdomain routing. The BGP router establishes a connection using TCP to each of its neighbors. BGP router can establish two types of sessions, external or internal. If the two BGP peers reside in two different domains or autonomous systems (or ASs), the session is known as an external BGP or an eBGP session. If the two BGP peers are in the same AS, then it said to be an internal BGP or iBGP session.
The traditional BGP only supports IPv4 unicast prefixes however MP-BGP enables support for address families for both IPv4 and IPv6 with unicast and multicast traffic types. To support address families, much like OSPFv3, MP-BGP differs from traditional BGP in several ways.
Multiprotocol-BGP is the protocol that is used to communicate VRF reachability information to all members of an MPLS VPN, hence MP-BGP must be configured on all PE devices.