Lab Objective:
Learn how to configure the OSPF routing protocol.
Lab Purpose:
OSPF is a link state routing protocol which scales very well for large to very large networks. It uses a link state algorithm to determine the best (shortest) path to take to a particular network. OSPF uses the concept of areas in order to determine which type of routing update to send. We will stick to area 0 in this lab for simplicity.
Lab Tool:
Packet Tracer
Lab Topology:
Please use the following topology to complete this lab exercise:

Lab Walkthrough:
Task 1:
Connect two routers together using a crossover cable.
Task 2:
Add the IP addresses to the routers connecting the interfaces and then the loopback interfaces. Hopefully you are getting familiar with this process now, so I’ll just walk you through R0 configuration.
Router>en
Router#conf t
Router(config)#hostname R0
R0(config)#
Enter configuration commands, one per line. End with CNTL/Z.
R0(config)#int lo0
R0(config-if)#ip add 10.1.1.1 255.255.240.0
R0(config-if)#int g0/0
R0(config-if)#ip add 192.168.1.1 255.255.255.252
R0(config-if)#no shut
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
Task 3:
Ping from R0 to R1 to check the connection works.
R0#ping 192.168.1.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.2, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 0/0/0 ms
Task 4:
Configure OSPF on both R0 and R1 to advertise the connected networks. OSPF requires you to add an area and a wildcard mask, rather than a subnet mask. This tells the router exactly which subnet you wish to advertise. As a quick cheat, you take whatever the subnet value is in each octet and take it away from 255, so:
255.255.240.0 gives you
0.0.15.255
255.255.255.252 gives you
0.0.0.3
The number following OSPF is only locally significant, so you need not match it on a neighbor router.
R0(config)#router ospf 10
R0(config-router)#network 10.1.1.0 0.0.15.255 area 0
R0(config-router)#network 192.168.1.0 0.0.0.3 area 0
R1(config)#router ospf 20
R1(config-router)#network 192.168.1.0 0.0.0.3 area 0
R1(config-router)#network 172.16.1.0 0.0.0.255 area 0
You should see the information message below appear when the link comes up.
00:48:11: %OSPF-5-ADJCHG: Process 20, Nbr 10.1.1.1 on GigabitEthernet0/0 from LOADING to FULL, Loading Done
Task 5:
Check the routing table with the ‘show ip route’ command and the routing configurations with the ‘show ip protocols’ command. Because we are using loopback interfaces, OSPF will advertise a/32 subnet. You can Google what to do about this, but it’s well outside the syllabus.
You can see that OSPF has 110 as its administrative distance, and the metric is 2, which, for OSPF, is the cost to get to the remote link.
R0#show ip route
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, E – EGP
i – IS-IS, 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
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.1.0.0/20 is directly connected, Loopback0
L 10.1.1.1/32 is directly connected, Loopback0
172.16.0.0/32 is subnetted, 1 subnets
O 172.16.1.1/32 [110/2] via 192.168.1.2, 00:01:19, GigabitEthernet0/0
192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
C 192.168.1.0/30 is directly connected, GigabitEthernet0/0
L 192.168.1.1/32 is directly connected, GigabitEthernet0/0
R0#show ip protocols
Routing Protocol is “ospf 10”
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 10.1.1.1
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
192.168.1.0 0.0.0.3 area 0
10.1.0.0 0.0.15.255 area 0
Routing Information Sources:
Gateway Distance Last Update
10.1.1.1 110 00:06:44
172.16.1.1 110 00:06:44
Distance: (default is 110)
Task 6:
Ping the remote network IP address. Feel free to try this on the R1 to R0 loopback also.
R0#ping 172.16.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/0/1 ms
Task 7:
There are many other commands you can use with every routing protocol, but they’re well outside the syllabus requirements. Try these if you wish:
R0#show ip ospf ?
<1-65535> Process ID number
border-routers Border and Boundary Router Information
database Database summary
interface Interface information
neighbor Neighbor list
virtual-links Virtual link information
<cr>
Notes:
We have just dipped our toes into OSPF here. It’s extensively covered in Cisco CCNP and partially in Cisco CCNA.