OSPF configuration examples

OSPF topology

Exercise 1: Configure OSPF in two routers and check Adjacency state, Routing table and LSDB

Steps:

1.Configure IP address in R1 and R2

2.Create one loopback interface in both routers and configure IP address

3.Enable OSPF and advertise networks

4.Check routing table, adjacency status and LSDB

 

R1 configuration:

Step 1: Configuring IP address in R1

R1#

R1#configure terminal

R1(config)#interface fastEthernet 0/0

R1(config-if)#ip address 192.168.1.1 255.255.255.0

R1(config-if)#no shutdown

R1(config-if)#exit

Step 2: Creating loopback interface

R1(config)#interface loopback 1

R1(config-if)#ip address 10.0.0.1 255.0.0.0

R1(config-if)#exit

R1(config)#exit

R1#

Step 3: Configuring OSPF

R1#

R1#configure terminal

R1(config)#router ospf 1

R1(config-router)#network 10.0.0.0 0.255.255.255 area 0

R1(config-router)#network 192.168.1.0 0.0.0.255 area 0

R1(config-router)#exit

R1(config)#exit

R1#

 

R2 configuration:

Step 1:Configuring IP address

R2#

R2#configure terminal

R2(config)#interface fastEthernet 0/0

R2(config-if)#ip address 192.168.1.2 255.255.255.0

R2(config-if)#no shutdown

R2(config-if)#exit

Step 2:Creating loopback interface

R2(config)#interface loopback 1

R2(config-if)#ip address 20.0.0.1 255.0.0.0

R2(config-if)#exit

R2(config)#exit

Step 3: Configuring OSPF

R2#

R2(config)#

R2(config)#router ospf 1

R2(config-router)#network 20.0.0.0 0.255.255.255 area 0

R2(config-router)#network 192.168.1.0 0.0.0.255 area 0

R2(config-router)#exit

R2(config)#exit

R2#

%OSPF-5-ADJCHG: Process 1, Nbr 10.0.0.1 on FastEthernet0/0 from LOADING to FULL, Loading Done

 

1. Checking adjacency state:

R2#show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface

10.0.0.1 1 FULL/BDR 00:00:37 192.168.1.1 FastEthernet0/0

2.Checking routing table

R2#show ip route ospf

10.0.0.0/32 is subnetted, 1 subnets

O 10.0.0.1 [110/11] via 192.168.1.1, 00:49:36, FastEthernet0/0

3. Checking LSDB

R2#show ip ospf database

OSPF Router with ID (20.0.0.1) (Process ID 1)

Router Link States (Area 0)

Link ID ADV Router Age Seq# Checksum Link count

10.0.0.1 10.0.0.1 1008 0x80000004 0x00F02C 2

20.0.0.1 20.0.0.1 1035 0x80000004 0x00E01D 2

Net Link States (Area 0)

Link ID ADV Router Age Seq# Checksum

192.168.1.2 20.0.0.1 1035 0x80000002 0x002572

R2#

4.Checking OSPF configuration settings

R2#show ip protocols

Routing Protocol is "ospf 1"

Outgoing update filter list for all interfaces is not set

Incoming update filter list for all interfaces is not set

Router ID 20.0.0.1

Number of areas in this router is 1. 1 normal 0 stub 0 nssa

Maximum path: 4

Routing for Networks:

20.0.0.0 0.255.255.255 area 0

192.168.1.0 0.0.0.255 area 0

Reference bandwidth unit is 100 mbps

Routing Information Sources:

Gateway Distance Last Update

10.0.0.1 110 00:49:49

Distance: (default is 110)

Exercise 2: Verify that DR and BDR is elected based on Router ID if priority is same.

ospf topology DR BDR election

Steps:

1.Configure IP address and create loopback interface in all routers.

(If loopback interfaces are configured, Router ID will the highest IP among loopback interfaces)

2. Configure OSPF and advertise all networks

3. Check adjacency states

For configuring OSPF and advertising networks use the same commands mentioned in exercise 1.

Below output shows the adjacency states and the elected DR/BDR for the above topology.

This output is taken from R1. As expected R4 is elected as DR because its Router ID is the highest among these routers.

R1#show ip ospf neighbor

NeighborID--Pri --State--Dead Time--Address--Interface

20.0.0.1--1--2WAY/DROTHER--00:00:36 192.168.1.2 FastEthernet0/0

30.0.0.1--1--FULL/BDR 00:00:33 192.168.1.3 FastEthernet0/0

40.0.0.1--1--FULL/DR 00:00:33 192.168.1.4 FastEthernet0/0

 

Exercise 3: Verify that if priority is different the device with highest priority is elected as DR.

Steps:

1. Configure priority in R1 as 10 and R2 as 5

2. Restart OSPF process to perform the adjacency formation again

3. Check DR/BDR status

 

1. Changing priority in R1 and R2

R1#

R1#configure terminal

R1(config)#interface fastEthernet 0/0

R1(config-if)#ip ospf priority 10

 

R2#

R2#configure terminal

R2(config)#interface fastEthernet 0/0

R2(config-if)#ip ospf priority 5

 

 

2. Restarting OSPF in R1 and R2

R1#clear ip ospf 1 process

Reset OSPF process? [no]: yes

 

R2#clear ip ospf 1 process

Reset OSPF process? [no]: yes

3. Checking the new DR and BDR

R4#show ip ospf neighbor

Neighbor ID Pri State Dead Time Address Interface

10.0.0.1 10 FULL/DR 00:00:31 192.168.1.1 FastEthernet0/0

20.0.0.1 5 FULL/BDR 00:00:39 192.168.1.2 FastEthernet0/0

30.0.0.1 1 2WAY/DROTHER 00:00:37 192.168.1.3 FastEthernet0/0

R4#

As expected here R1 which has the highest priority is elected as DR and R2 with second most priority is elected as BDR.

 

Exercise 4: Verify that external routes are not showing in routing table of STUB area.

ospf stub area topology

Steps:

1.In the above topology, configure the network between R1 and R2 in area 1 and network between R2 and R3 in area 0

2. Configure a static route in R3 and redistribute static networks in to OSPF

3.Verify that redistributed networks are shown in routing table of R1

4.Change area 1 to stub area in R1 and R2

5.Check the routing table of R1 again

If Area 1 is configured as a stub area, R2 which is acting as ABR for area 1 will not allow LSA 4 and 5 to pass in to Area 1. Instead R2 will inject a default route to Area 1 which can be used by R1 to send packets to external networks.

Configuring OSPF in R1 and R2

R1(config)#router ospf 1

R1(config-router)#network 192.168.1.0 0.0.0.255 area 1

 

R2(config)#router ospf 1

R2(config-router)#network 192.168.1.0 0.0.0.255 area 1

R2(config-router)#network 192.168.2.0 0.0.0.255 area 0

 

Configuring static route and redistribution in R3

R3(config)#ip route 40.0.0.0 255.0.0.0 loopback 1

R3(config)#router ospf 1

R3(config-router)#network 192.168.2.0 0.0.0.255 area 0

R3(config-router)#redistribute static subnets

 

Routing table of R1 before Stub area is configured

R1(config-router)#do show ip route ospf

O E2 40.0.0.0/8 [110/20] via 192.168.1.2, 00:00:48, FastEthernet0/0

O IA 192.168.2.0/24 [110/20] via 192.168.1.2, 00:01:49, FastEthernet0/0

R1 is showing the redistributed network 40.0.0.0 now . Type “O E2” indicates that this route is learned from LSA 5.

 

Reconfiguring Area 1 as Stub area:

R1(config)#router ospf 1

R1(config-router)#area 1 stub

 

R2(config)#router ospf 1

R2(config-router)#area 1 stub

 

Note: When an area is changed to Stub area , adjacency will be reestablished.

Routing table of R1 after stub area configuration

R1#show ip route ospf

O IA 192.168.2.0/24 [110/20] via 192.168.1.2, 00:33:59, FastEthernet0/0

O*IA 0.0.0.0/0 [110/11] via 192.168.1.2, 00:33:59, FastEthernet0/0

R1#

As expected a default route is present in routing table of R1.

R2 which is the ABR for area 1 has injected a default route in to area 1. LSA 3 is used to inject this default route. You can see the code “O*IA” which shows that this route is learned from LSA 3.

 

Related:

Cisco RIP configuration commands

Cisco basic commands


CONTACT

Contact us and we'll get back to you within 24 hours.

#11, 8th cross, Indiranagar 1st stage, Bangalore, India

Queries?
You can connect with us on Whatsapp 8884 884 844