OSPF Configuration


OSPF Single area

Let’s start by configuring OSPF between R1 & R2 in area 10.

R1 will be configured with a network statement.
R2 will be configured with Interface specific method.
Loopback interfaces 1.1.1.1/32 & 2.2.2.2/32 will be added to R1 & R2 respectively and added to OSPF process.

OSPF Single Area
R1(config)#router ospf 10 
R1(config-router)#router-id 1.1.1.1 
R1(config-router)#network 10.1.2.1 0.0.0.0 area 10 
R1(config-router)#network 1.1.1.1 0.0.0.0 area 10 
R1(config-router)#passive-interface lo0
R2(config)#router ospf 10 
R2(config-router)#router-id 2.2.2.2 
R2(config-router)#passive-interface lo0 
R2(config-router)#exit 

R2(config)#int gi0/0 
R2(config-if)#ip ospf 10 area 10 
R2(config)#int int lo0 
R2(config-if)#ip ospf 10 area 10
R1#sh ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/BDR 00:00:33 10.1.2.2 GigabitEthernet0/0

R1#sh ip route ospf
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route, H - NHRP, l - LISP
a - application route
+ - replicated route, % - next hop override, p - overrides from PfR

Gateway of last resort is not set

2.0.0.0/32 is subnetted, 1 subnets
O E2 2.2.2.2 [110/20] via 10.1.2.2, 00:03:42, GigabitEthernet0/0

Link between R1 & R2 is Ethernet, so broadcast and that is why a DR and BDR election must take place. In this example R1 is DR and R2 BDR as can be seen below.

R2#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
1.1.1.1 1 FULL/DR 00:00:33 10.1.2.1 GigabitEthernet0/0

R1#sh ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 1 FULL/BDR 00:00:30 10.1.2.2 GigabitEthernet0/0

OSPF Multiple areas

Let’s add a new area 20 and “glue” these 2 areas with backbone area zero.

R2 is now an ABR.
R4 is ABR.
R3 is a backbone router.

OSPF Multiple Areas
R2 

interface GigabitEthernet0/2
ip address 10.2.3.2 255.255.255.0
ip ospf 10 area 0
!
router ospf 10
router-id 2.2.2.2
passive-interface Loopback0
R3

interface Loopback0
ip address 3.3.3.3 255.255.255.255
ip ospf 10 area 0
!
interface GigabitEthernet0/1
ip address 10.3.4.3 255.255.255.0
ip ospf 10 area 0
!
interface GigabitEthernet0/2
ip address 10.2.3.3 255.255.255.0
ip ospf 10 area 0
!
router ospf 10
router-id 3.3.3.3
passive-interface Loopback0
R4

interface Loopback0
ip address 4.4.4.4 255.255.255.255
ip ospf 10 area 0
!
interface GigabitEthernet0/0
ip address 10.4.5.4 255.255.255.0
ip ospf 10 area 20
!
interface GigabitEthernet0/1
ip address 10.3.4.4 255.255.255.0
ip ospf 10 area 0
!
router ospf 10
router-id 4.4.4.4
passive-interface Loopback0
R5

interface Loopback0
ip address 5.5.5.5 255.255.255.255
ip ospf 10 area 20
!
interface GigabitEthernet0/0
ip address 10.4.5.5 255.255.255.0
ip ospf 10 area 20
!
router ospf 10
router-id 5.5.5.5
passive-interface Loopback0

OSPF Network Types

OSPF supports following network types, each has its own requirements and more adequate depending on the designed topology.

  • broadcast  – Specify OSPF broadcast multi-access network
  • non-broadcast – Specify OSPF NBMA network
  • point-to-multipoint – Specify OSPF point-to-multipoint network
  • point-to-point – Specify OSPF point-to-point network

In next step we will change our network type from Broadcast to point-to-point.

OSPF Multiple Areas
R1#
R1#sh ip ospf interface gigabitEthernet 0/0
GigabitEthernet0/0 is up, line protocol is up 
Internet Address 10.1.2.1/24, Area 10, Attached via Network Statement
Process ID 10, Router ID 1.1.1.1, Network Type BROADCAST, Cost: 1  <----------------Original network type
-------- Omitted -------------------
R1# 
R1#
R1#conf t
R1(config)#int gigabitEthernet 0/0
R1(config-if)#ip ospf network point-to-point 
R1(config-if)#
*Feb 17 08:16:09.017: %OSPF-5-ADJCHG: Process 10, Nbr 2.2.2.2 on GigabitEthernet0/0 from FULL to DOWN, Neighbor Down: Interface down or detached
*Feb 17 08:16:09.046: %OSPF-4-NET_TYPE_MISMATCH: Received Hello from 2.2.2.2 on GigabitEthernet0/0 indicating a potential 
network type mismatch^Z
R1#
*Feb 17 08:16:24.567: %OSPF-5-ADJCHG: Process 10, Nbr 2.2.2.2 on GigabitEthernet0/0 from LOADING to FULL, Loading Done
R1#
R1#sh ip ospf interface gigabitEthernet 0/0
GigabitEthernet0/0 is up, line protocol is up
Internet Address 10.1.2.1/24, Area 10, Attached via Network Statement
Process ID 10, Router ID 1.1.1.1, Network Type POINT_TO_POINT, Cost: 1 <—————-Changed network type
R1#sh ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface
2.2.2.2 0 FULL/ – 00:00:36 10.1.2.2 GigabitEthernet0/0 <—————-No DR or BDR

ASBR and external routes types

Let’s turn R5 to an Autonomous System Boundary Router or ASBR. Essentially R5 will redistribute routes into Area 20. For this purpose we create 2 new loopbacks:

  • Loopback 10 – 172.16.10.1/24
  • Loopback 10 – 172.16.20.1/24

When we come to redistribute them, LP10 will be as Type 1 and LP20 as type 2.

route-map LP_to_OSPF permit 10 <---- Configure a Route Map matching each loopback or prefix
match interface Loopback10
set metric-type type-1
!
route-map LP_to_OSPF permit 20
match interface Loopback20
set metric-type type-2
!
router ospf 10
router-id 5.5.5.5
redistribute connected subnets route-map LP_to_OSPF <---- Redistribute connected subnets as per Route Map settings

Let’s examine the metrics of the redistributed subnets. Default metric when redistributing OSPF is 20, and this will metric will remain unchanged for E2 types external routes. However for E1 types, the metric is default + metric to get to the ASBR.

In next example, metric is set on the route map to 100 for both E1 & E2 types. On the show up route ospf, only E2 type remains unchanged, while E1 changes accordingly.


R5(config)#route-map LP_to_OSPF permit 10
R5(config-route-map)#set metric 100
R5(config-route-map)#route-map LP_to_OSPF permit 20
R5(config-route-map)#set metric 100 
R1#sh ip route ospf
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
——— omitted ———————

172.16.0.0/24 is subnetted, 2 subnets
O E1 172.16.10.0 [110/104] via 10.1.2.2, 00:00:07, GigabitEthernet0/0 <--- 100 + cost to get  to ASBR which is 4
O E2 172.16.20.0 [110/100] via 10.1.2.2, 00:49:43, GigabitEthernet0/0 <--- Metric changed from default 20 to 100

Defaulte route Advertisement

In OSPF, before a default route is advertised, it must be in the RIB or routing table. In next example, I add a static default route on R5 and advertise it in OSPF.


R5(config)#ip route 0.0.0.0 0.0.0.0 null 0 <---- Adding static route to Null0
R5(config)#do sh ip route
------ Omitted -------
S* 0.0.0.0/0 is directly connected, Null0  <—- checking my default route is in routing table

R5(config)#router ospf 10
R5(config-router)#default-information originate metric 200 <---- Advertising default route with a metric of 200

validation on R1


R1#sh ip route ospf
----- omitted ----------
O*E2 0.0.0.0/0 [110/200] via 10.1.2.2, 00:00:17, GigabitEthernet0/0