You are on page 1of 8

ETTI. Lab: OSPF (V1.

1)

Octavian Catrina, 2014

Lab: OSPF Routing Protocol


Overall objective
The purpose of this lab is to study link state routing and the OSPF (Open Shortest Path First) intra-domain
routing protocol. OSPF is an IETF standard, widely used in the Internet and in enterprise networks.
Prerequisites
A comprehensive description of link state routing and the OSPF protocol is available in the course material.
Review this material before the lab. You should be familiar with the basic concepts and operation of IP
networks, link-state routing, and the OSPF protocol.
Case study
In this lab, you'll carry out a series of experiments in order to study router configuration for IP and OSPF and
the operation of these protocols. You'll use for this purpose an IP network with the topology shown in Figure
1. The network consists of Cisco routers interconnected by Ethernet multi-access links (Ethernet switches)
and serial point-to-point links.

Figure 1. IP network topology.


Summary of learning objectives
You will set up the network shown in Figure 1 and study the following topics:

OSPF configuration on Cisco routers for single area and for multiple areas.
Link state routing and OSPF operation for a single area in typical situations (including adjacency
setup and topology changes).

OSPF operation for multiple areas.


You will learn how the protocol works by examining the status of the routers using Cisco IOS commands and
by studying the exchanged packets using a protocol analyzer.
Overview of Cisco IOS Commands for OSPF Configuration
This section provides a quick reference for the Cisco IOS commands that will be used during the lab in order
to configure OSPF, examine the router status (protocol configuration and operation), and troubleshooting.
- Enter OSPF configuration mode and start an OSPF process on the router:
router(config)#router ospf process-id
The process-id is a local value used to distinguish different OSPF processes on a router. Use any value.
- Activate OSPF on an interface and assign the interface to an area:
router(config-router)#network address wildcard-mask area area-id
The wildcard mask allows assigning several interfaces to the same area with one command: 0 is a match
1

ETTI. Lab: OSPF (V1.1)

Octavian Catrina, 2014

and 1 is a "don't care" bit, e.g. 0.0.255.255 indicates a match in the first two bytes of the address.
- Modify the priority of the router for Designated Router (DR) and Backup Designated Router (BDR) election
on a multi-access network:
router(config-if)#ip ospf priority number (from 0 to 255)
Priority 0 indicates that the router cannot be DR/BDR.
- Set up a loopback interface to be used as OSPF Router-ID:
router(config)#interface loopback 0
router(config-if)#ip address address mask
- Configure the OSPF Router-ID:
router(config-router)#router-id address
- Modify the cost (metric) for an interface/link:
router(config-if)#ip ospf cost cost (from 1 to 65535)
8

Cisco's OSPF default cost assignment is based on the links bandwidth using the formula 10 /Bandwidth.
All interfaces connected to the same link must agree on the link's cost. Examples of default costs: 10 for
10BASE-T Ethernet. 1 for 100-Mbps Fast Ethernet. 64 for T1 (1.544-Mbps serial link). Use the
bandwidth command to specify the real speed for a serial link (e.g., 1785 for 56-kbps serial link.).
- Instruct an ABR to summarize routes for an area (when advertised in other areas):
router(config-router)#area area-id range address mask
Advertises a single route to the aggregated address block identified by the address and mask.
- Configure an area as a stub area. On each router in the area:
router(config-router)#area area-id stub
- Examine OSPF configuration and state:
router# show ip ospf [interface | neighbor | database]
- Examine IP routing protocols and routing table:
router# show ip protocols
router# show ip route
- OSPF debugging:
router# debug ip ospf [...]

1. Preliminary Network Setup


We use the network shown in Figure 1 for all the experiments carried out in this lab. The instructions given in
the following assume that the experiments are carried out using the network emulator GNS3.
1.1. Load the initial GNS project.
You start with a GNS project that contains the network topology shown in Figure 1. The initial router
configuration contains only the host name and default settings.
1.2. Start the routers and check the CPU load.
Start a router using GNS (right-click on the router and select Start) and then check the CPU load (on
Windows, start the Task Manager and select the Performance tab). Wait until the router boots up.

ETTI. Lab: OSPF (V1.1)

Octavian Catrina, 2014

If the CPU load does not decrease to a low level, adjust the Idle PC parameter (right-click on the router and
select Idle-PC); ask the instructor if necessary.
Then start the entire network, and check that the CPU load falls to a low level once all routers boot up.
1.3. Start router consoles.
Start consoles for all the 5 routers using GNS (use the Console button in the toolbar or right-click on the
router and select Console). In each console window you should see the Cisco CLI prompt router-name#
for privileged mode, that allows you to enter any command for configuring the router or examining its status.
1.4. Start packet capture.
Start packet capture on the interface e0/0 of router RC using GNS (right-click on the link and select Start
capturing). We'll examine the captured packets later on during the experiments.
For each step, verify if the current router configuration and operation are correct, then save the configuration
and the GNS project, before proceeding to the next step. To speed up the configuration process, edit at each
step the batches of commands for all the routers you configure using a text editor, and then copy each batch
from the text editor to the router's console window (right-click).

2. Basic IP Configuration
2.1. Configure IP on all routers according to Figure 1.
The sequence of configuration commands for the router RC is listed below; the configuration of the other
routers is similar.
conf term
interface e0/0
ip address 172.16.3.2 255.255.255.0
no shutdown
interface e0/1
ip address 172.17.1.1 255.255.255.0
no shutdown
interface s1/0
ip address 172.16.4.2 255.255.255.0
no shutdown

Enter global configuration mode.


Enter interface configuration mode for e0/0.
Configure the IP address and mask for e0/0.
Turn on the interface.
Similar for the other interfaces.

2.2. Configure the loopback interface.


A loopback interface is usually set up as part of the OSPF configuration in order to be used as OSPF
Router ID. This makes the Router ID stable, because a loopback interface is always up, while a physical
interface can occasionally go down, for various reasons.
Configure on each router the interface loopback 0 with the following addresses:
RA
RB
RC
172.16.100.1/32 172.16.100.2/32 172.17.100.1/32

RD
172.17.100.2/32

RE
172.18.100.1/32

The sequence of configuration commands for the router RC is listed below; the configuration of the other
routers is similar.
conf term
interface loopback 0
ip address 172.17.100.1 255.255.255.255

Enter global configuration mode.


Enter interface configuration mode for loopback 0.
Configure the IP address and mask.

2.3. Verify the router configuration (show run), save it (copy run start), then save the GNS project.

ETTI. Lab: OSPF (V1.1)

Octavian Catrina, 2014

2.4. Examine the status of the router interfaces using the commands listed below.
show interface if-name

Show the status of the interface if-name.


Example: show int e0/0

Are all the interfaces used in the network topology shown in Figure 1 working properly? (You should see:
interface if-name is up, line protocol is up.)
Are the IP addresses of the interfaces correctly configured?
2.5. Examine the status of IP routing using the commands listed below.
show ip route

Show the routing table.

show ip protocols

Show the active routing protocols and their status.

The initial routing table of each router should contain only the routes to directly connected networks. We
haven't started so far any routing protocol, so the second command should display nothing.

3. OSPF Configuration and Operation for a Single Area


We'll first experiment with OSPF in the single area setting, as shown in Figure 2.

Figure 2. Configuration with a single OSPF area.


3.1. Configure OSPF for a single area.
The sequence of configuration commands for the router RC is listed below; the configuration of the other
routers is similar.
conf term
router ospf 1
router-id 172.17.100.1
network 172.16.0.0 0.0.255.255 area 0
network 172.17.0.0 0.0.255.255 area 0

Enter global configuration mode.


Enter OSPF config. mode, start OSPF process 1.
Configure the OSPF Router-ID.
Activate OSPF routing for networks with addresses
in 172.16.0.0/16 and 172.17.0.0/16, and assign all
these networks to area 0.

3.2. Verify the router configuration (show run), save it (copy run start), then save the GNS project.
3.3. Examine the current OSPF status.
Note that in our setting it may take several tens of seconds until the protocol reaches a stable state.
4

ETTI. Lab: OSPF (V1.1)

Octavian Catrina, 2014

Examine the status of the routers after OSPF configuration using the following commands:
show ip protocols

Show the active routing protocols and their status.

Is OSPF running? What is the Router-ID? For how many areas does it work?
Does it report all the other routers as routing information sources?
show ip ospf

OSPF status and parameters.

show ip ospf interface

OSPF status and parameters for each interface.

show ip ospf neighbor

OSPF adjacencies.

The information displayed by the second command is different depending on interface type, Ethernet
(multi-access, broadcast) or Serial (point-to-point). Check for each interface:
- Is OSPF running for that interface? To what area is the interface assigned?
- What is the link cost and type of network connected to the interface?
- What neighbors have been found in the network connected to the interface? Is the router DR or BDR or
none, for that network? (Explain.) What adjacencies have been established? (Explain.)
3.4. Examine the OSPF link costs (metric).
The default OSPF link cost on Cisco routers is computed based on the links bandwidth (data rate) using
the formula cost = 108/Bandwidth [bps]. Examples of default costs: 1 for 100-Mbps Fast Ethernet, 10 for
10 Mbps Ethernet, 64 for T1 serial interfaces with 1.544 Mbps bandwidth.
You can set the link cost for an interface to any value using in interface configuration mode the command:
router(config-if)#ip ospf cost cost
Alternatively, you can set the bandwidth of the interface, used in the default link cost calculation, using in
interface configuration mode the command (value in Kbps):
router(config-if)# bandwidth value
We shall not change the default values in this lab. Just check if the link cost matches the bandwidth of the
interface using show ip ospf interface.
3.5. Examine the routing table (show ip route).
- Which routes are provided by OSPF? Does the router have routes to all the subnets?
- The path metric for each route is displayed as a pair of values, e.g., 110/74. The second value is the
actual OSPF cost (the first one is an administrative metric). Check if the path cost, interface, and next hop
of the routes correspond indeed to the shortest paths and the link costs.
- Examine the routing tables and figure out what happens when there are alternate paths to a destination
with the same cost and with different costs. Do you see alternate paths for any route?
3.6. Examine the OSPF topological database.
Examine the Link State Advertisements (LSA) in the OSPF topological database using the following
commands:
show ip ospf database router

Router LSAs.

show ip ospf database network

Network LSAs.

show ip ospf database summary

Summary LSAs.

How did OSPF acquire this information? How is this information used by OSPF?
Compare the information in the database with the network topology.
3.7. Test network connectivity and paths.
Test connectivity between the routers RA and RE using the command:
5

ETTI. Lab: OSPF (V1.1)

Octavian Catrina, 2014

ping 172.18.2.1
Determine the path used to forward packets from RA to RE using the command:
traceroute ip 172.18.2.1
Is it the shortest path?

4. OSPF Protocol Operation


We now take a closer look at the messages exchanged by the OSPF protocol, using a protocol analyzer.
Note that OSPF uses the multicast address 224.0.0.5 (link scope) to send OSPF messages to all OSPFaware routers on a network segment (Hello, Update, Ack).
4.1. Start the Wireshark protocol analyzer from GNS in order to examine the packets captured so far (rightclick on the host name in the Captures window and select Wireshark). In Wireshark, set ospf as filter
expression, in order to display only the OSPF packets.
How are the OSPF messages encapsulated?
4.2. Examine the initial Hello packets sent by RB and RC.
Check the information in these packets. Notice how RB and RC discover each other as OSPF neighbors
after several Hello packet exchanges, before proceeding to establish an adjacency relation.
What is the purpose of the Hello packets? Why are they sent periodically? What is the meaning of the
time intervals advertised in these packets?
4.3. Examine the packets exchanged by OSPF in order to set up the adjacency relation between RB and
RC: Database Description, LS Request, LS Update, and LS Acknowledge (the adjacency setup protocol
is discussed in the OSPF lecture). Notice that, after setting up the adjacency, RB and RC exchange
additional LS Updates, that arrive later from the other routers.
- Look at the contents of these packets (link state information, mainly) and explain how does OSPF
update and synchronize the topological databases of the two routers when an adjacency is set up.
- What types of LSA are exchanged? Compare the information in the LSAs with the network topology and
with the topological database displayed by the routers (show ip ospf database).
- Look at the contents of the Hello packets after adjacency setup. What has changed? Which router is the
DR for the (multi-access, broadcast) network 172.16.3.0/24? Which one is the BDR?
- Notice that the routers exchange twice some of the LS Update packets. What is the explanation?

5. Recovery After Link Failure


During the next experiments you'll see how OSPF updates the topological database and the routing tables
when the network topology changes. We'll trace the packets exchanged on the interface e0/0 of RC using
Wireshark (start GNS packet capture for this interface, if stopped).
5.1. Link failure without alternate routes: 172.16.1.0/24 becomes unreachable.
- Shut down the interface e1/0 of the router RA using the commands:
conf term
int e1/0
shutdown
- Check that the route to 172.16.1.0/24 has been removed from the routing tables of all routers.
- Examine using Wireshark the OSPF packets exchanged by RC after this event (you should see an LS
Update followed by LS Acknowledge). Explain what happened.
- Turn on the interface e1/0 of the router RA using the commands:
conf term
int e1/0
6

ETTI. Lab: OSPF (V1.1)

Octavian Catrina, 2014

no shutdown
- Check that the route to 172.16.1.0/24 is back in the routing tables of all routers.
- Examine using Wireshark the OSPF packets exchanged by RC after this event (you should see an LS
Update followed by LS Acknowledge). Explain what happened.
5.2. Link failure with alternate routes: failed link between RA and RC.
- Examine the route to 172.16.1.0/24 on RD.
- Shut down the interface s0/1 of the router RA. Check what happens to the route to 172.16.1.0/24.
- Turn on the interface s0/1 of the router RA. Check what happens to the route to 172.16.1.0/24.

6. OSPF Configuration and Operation for Multiple Areas


In order to improve scalability, OSPF provides mechanisms that support a two-level network hierarachy,
consisting of a backbone area (Area 0) that interconnects a number of other areas.
We modify now the OSPF configuration in order to obtain the topology with multiple areas shown in Figure 3.

Figure 3. Configuration with multiple OSPF areas.


6.1. Shut down OSPF on all routers using the following commands:
conf term
no router ospf 1

Enter global configuration mode.


Shut down OSPF process 1.

6.2. Configure OSPF for multiple areas according to Figure 3.


The sequence of configuration commands for the router RC is listed below; the configuration of the other
routers is similar.
conf term
router ospf 1
router-id 172.17.100.1
network 172.16.0.0 0.0.255.255 area 1

Enter global configuration mode.


Enter OSPF config. mode, start OSPF process 1.
Configure the OSPF Router-ID.
Activate OSPF routing for networks with addresses
in 172.16.0.0/16 and assign them to area 1.
Activate OSPF routing for networks with addresses
in 172.17.0.0/16 and assign them to area 0.

network 172.17.0.0 0.0.255.255 area 0

6.3. Verify the router configuration (show run), save it (copy run start), then save the GNS project.
6.4. Examine the current OSPF status.
7

ETTI. Lab: OSPF (V1.1)

Octavian Catrina, 2014

Examine the status of the routers after OSPF configuration using the following commands:
show ip protocols

Show the active routing protocols and their status.

show ip ospf

OSPF status and parameters.

Is OSPF running? For how many areas does it work? Does it report all the other routers as routing
information sources? Is the router an ABR (Area Border Router)?
6.5. Examine the routing table (show ip route).
What has changed with respect to the routing tables in the configuration with a single area?
6.6. Examine the OSPF topological database.
Examine the LSAs in the topological database of the routers using the following commands:
show ip ospf database

All LSAs.

show ip ospf database database-summary

Summary of LSAs.

What has changed with respect to the topological database in the configuration with a single area?

7. Route Summarization
OSPF supports route summarization (aggregation) in order to reduce the size of the routing tables and the
amount of routing information exchanged between areas. This feature is disabled in the default configuration.
In the next experiment, you'll enable it on the Area Border Routers (ABRs) in order to aggregate inter-area
routes.
7.1. Configure on the ABRs route summarization for each area.
The sequence of configuration commands for the router RC is listed below; the configuration of the other
ABR, RD, is similar.
conf term
router ospf 1

Enter global configuration mode.


Enter OSPF config. mode.
Activate route summarization in area 1 for networks
with addresses in 172.16.0.0/16 and in area 0 for
networks with addresses in 172.17.0.0/16.

area 1 range 172.16.0.0 255.255.0.0


area 0 range 172.17.0.0 255.255.0.0

7.2. Examine the routing tables.


What has changed in the routing tables after enabling route summarization?

You might also like