Dynamic Routing Using OSPF

 

Experiment: Dynamic Routing Using OSPF

1. Aim

To configure Open Shortest Path First (OSPF) dynamic routing between two routers in Cisco Packet Tracer and verify automatic exchange of routing information and communication between two different LANs.


2. Objectives

After completing this experiment, students should be able to:

  1. Create two separate LANs using switches.
  2. Connect two routers through an inter-router network.
  3. Configure IPv4 addresses on PCs and router interfaces.
  4. Configure default gateways on PCs.
  5. Understand the need for routing between different IP networks.
  6. Configure OSPF on Cisco routers.
  7. Understand the concept of an OSPF area.
  8. Establish an OSPF neighbor relationship between two routers.
  9. Verify OSPF-learned routes using the routing table.
  10. Verify OSPF neighbor information.
  11. Test end-to-end connectivity using ping.
  12. Use tracert to observe the path between networks.
  13. Understand the difference between static routing, RIP, and OSPF.

3. Theory

OSPF (Open Shortest Path First) is a link-state dynamic routing protocol used to exchange routing information between routers.

Unlike static routing, where routes are manually entered, OSPF allows routers to automatically discover and learn routes.

In this experiment, we use two routers:

             Router0              Router1
                |                    |
                |                    |
             LAN 1                LAN 2

Router0 is directly connected to:

192.168.1.0/24
10.0.0.0/30

Router1 is directly connected to:

10.0.0.0/30
192.168.2.0/24

Initially, Router0 does not know about:

192.168.2.0/24

and Router1 does not know about:

192.168.1.0/24

OSPF allows the routers to exchange information so that each router learns the remote network.


4. Network Topology

We will use the same topology as the previous RIP experiment so that we can directly compare RIP and OSPF.

                    OSPF ROUTING DOMAIN
                  Area 0 / Backbone Area

 LAN 1                                                LAN 2
192.168.1.0/24                                     192.168.2.0/24

 PC0       PC1                                     PC2       PC3
  |         |                                       |         |
  |         |                                       |         |
  +----+----+                                       +----+----+
       |                                                 |
    Switch0                                           Switch1
       |                                                 |
       |                                                 |
     G0/0                                               G0/1
   Router0                                               Router1
     G0/1                                               G0/0
       +--------------- 10.0.0.0/30 --------------------+

A simpler representation:

      LAN 1                                      LAN 2
 192.168.1.0/24                              192.168.2.0/24

 PC0     PC1                                  PC2     PC3
  |       |                                    |       |
  +--- Switch0 --- Router0 ===== Router1 --- Switch1 ---+
                       |          |
                     G0/1       G0/0
                   10.0.0.1   10.0.0.2

                    OSPF Area 0






5. IP Addressing Scheme

We will use three networks.

LAN 1

192.168.1.0/24

Router-to-Router Network

10.0.0.0/30

LAN 2

192.168.2.0/24

Complete Addressing Table

DeviceInterfaceIP AddressSubnet MaskDefault Gateway
PC0    FastEthernet0    192.168.1.10    255.255.255.0192.168.1.1
PC1    FastEthernet0    192.168.1.11    255.255.255.0192.168.1.1
Router0    G0/0    192.168.1.1    255.255.255.0    —
Router0    G0/1    10.0.0.1    255.255.255.252    —
Router1    G0/0    10.0.0.2    255.255.255.252    —
Router1    G0/1    192.168.2.1    255.255.255.0    —
PC2    FastEthernet0    192.168.2.10    255.255.255.0192.168.2.1
PC3    FastEthernet0    192.168.2.11    255.255.255.0192.168.2.1

6. Devices Required

DeviceQuantity
Cisco Router2
Cisco 2960 Switch2
PC4
Copper Straight-Through Cable6
Router-to-router Ethernet cable1

Cable connections

LAN 1:

  • PC0 → Switch0
  • PC1 → Switch0
  • Switch0 → Router0

Router connection:

  • Router0 → Router1

LAN 2:

  • Router1 → Switch1
  • Switch1 → PC2
  • Switch1 → PC3

7. Important OSPF Concepts

Before beginning the configuration, students should understand these terms.

TermMeaning
OSPF    Open Shortest Path First
Link-state protocol    Routing protocol that builds knowledge of network topology
Area    Logical grouping of OSPF routers/networks
Area 0    OSPF backbone area
Neighbor    OSPF router with which a routing relationship is established
Router ID    Unique identifier of an OSPF router
Cost    OSPF routing metric
SPF    Shortest Path First algorithm

For this experiment, both routers will belong to Area 0.


8. Procedure

Students should perform the following tasks in the given order.


Task 1: Start Cisco Packet Tracer

  1. Open Cisco Packet Tracer.
  2. Create a new blank workspace.

Task 2: Place Two Routers

  1. Select Network Devices → Routers.
  2. Select a router with at least two Ethernet interfaces.
  3. Place two routers.
  4. Use:
Router0
Router1

Task 3: Place Two Switches

Place two Cisco 2960 switches:

Switch0 → LAN 1
Switch1 → LAN 2

Task 4: Place Four PCs

Place:

PC0
PC1
PC2
PC3

Arrange them as:

                 Router0              Router1
                    |                    |
                 Switch0              Switch1
                /       \            /       \
              PC0       PC1         PC2       PC3

Task 5: Connect LAN 1

Use Copper Straight-Through cables.

Connect:

PC0 FastEthernet0 → Switch0 Fa0/1

PC1 FastEthernet0 → Switch0 Fa0/2

Switch0 Fa0/24 → Router0 G0/0

Task 6: Connect Router0 and Router1

Connect:

Router0 G0/1
      |
      | Ethernet link
      |
Router1 G0/0

Use the appropriate cable for the router interfaces in your Packet Tracer model.


Task 7: Connect LAN 2

Connect:

Router1 G0/1 → Switch1 Fa0/24

Switch1 Fa0/1 → PC2 FastEthernet0

Switch1 Fa0/2 → PC3 FastEthernet0

The complete topology should now be:

      PC0       PC1                              PC2       PC3
       |         |                                |         |
       +----+----+                                +----+----+
            |                                          |
         Switch0                                    Switch1
            |                                          |
            |                                          |
         G0/0                                        G0/1
       Router0                                      Router1
         G0/1                                        G0/0
            +------------- 10.0.0.0/30 ---------------+

9. Configure the PCs

Task 8: Configure PC0

Go to:

PC0 → Desktop → IP Configuration

Enter:

IP Address:       192.168.1.10
Subnet Mask:      255.255.255.0
Default Gateway:  192.168.1.1

Task 9: Configure PC1

Enter:

IP Address:       192.168.1.11
Subnet Mask:      255.255.255.0
Default Gateway:  192.168.1.1

Task 10: Configure PC2

Enter:

IP Address:       192.168.2.10
Subnet Mask:      255.255.255.0
Default Gateway:  192.168.2.1

Task 11: Configure PC3

Enter:

IP Address:       192.168.2.11
Subnet Mask:      255.255.255.0
Default Gateway:  192.168.2.1

10. Configure Router0

Task 12: Configure Router0 G0/0

Click:

Router0 → CLI

Enter:

Router> enable
Router# configure terminal
Router(config)# interface gigabitEthernet 0/0
Router(config-if)# ip address 192.168.1.1 255.255.255.0
Router(config-if)# no shutdown
Router(config-if)# exit

Task 13: Configure Router0 G0/1

Enter:

Router(config)# interface gigabitEthernet 0/1
Router(config-if)# ip address 10.0.0.1 255.255.255.252
Router(config-if)# no shutdown
Router(config-if)# exit
Router(config)# end

11. Configure Router1

Task 14: Configure Router1 G0/0

Click:

Router1 → CLI

Enter:

Router> enable
Router# configure terminal
Router(config)# interface gigabitEthernet 0/0
Router(config-if)# ip address 10.0.0.2 255.255.255.252
Router(config-if)# no shutdown
Router(config-if)# exit

Task 15: Configure Router1 G0/1

Enter:

Router(config)# interface gigabitEthernet 0/1
Router(config-if)# ip address 192.168.2.1 255.255.255.0
Router(config-if)# no shutdown
Router(config-if)# exit
Router(config)# end

12. Verify Router Interfaces

Task 16: Verify Router0

On Router0:

show ip interface brief

Expected:

InterfaceIP AddressStatusProtocol
G0/0192.168.1.1upup
G0/110.0.0.1upup

Task 17: Verify Router1

On Router1:

show ip interface brief

Expected:

InterfaceIP AddressStatusProtocol
G0/010.0.0.2upup
G0/1192.168.2.1upup

Checkpoint

Do not proceed until the router interfaces are showing:

up
up

13. Verify the Router-to-Router Link

Task 18: Ping Router1 from Router0

On Router0:

ping 10.0.0.2

Expected:

Successful


Task 19: Ping Router0 from Router1

On Router1:

ping 10.0.0.1

Expected:

Successful


14. Test Connectivity Before OSPF

This is an important teaching step.

Task 20: Test PC0 → PC1

From PC0:

ping 192.168.1.11

Expected:

Successful


Task 21: Test PC2 → PC3

From PC2:

ping 192.168.2.11

Expected:

Successful


Task 22: Test PC0 → PC2

From PC0:

ping 192.168.2.10

Expected:

Failure

Why?

Router0 does not yet know how to reach:

192.168.2.0/24

This gives students a clear reason for configuring OSPF.


15. Examine the Routing Table Before OSPF

Task 23: Check Router0

Enter:

show ip route

Router0 should have routes for:

192.168.1.0/24
10.0.0.0/30

but not:

192.168.2.0/24

Task 24: Check Router1

Enter:

show ip route

Router1 should have routes for:

10.0.0.0/30
192.168.2.0/24

but not:

192.168.1.0/24

16. Configure OSPF on Router0

Task 25: Start OSPF

On Router0:

Router0> enable
Router0# configure terminal
Router0(config)# router ospf 1

Here:

1

is the OSPF process ID.

It is locally significant to the router.


Task 26: Advertise LAN 1

Enter:

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

Task 27: Advertise the Router-to-Router Network

Enter:

Router0(config-router)# network 10.0.0.0 0.0.0.3 area 0

Then:

Router0(config-router)# end

Complete Router0 OSPF configuration

Router0# configure terminal
Router0(config)# router ospf 1
Router0(config-router)# network 192.168.1.0 0.0.0.255 area 0
Router0(config-router)# network 10.0.0.0 0.0.0.3 area 0
Router0(config-router)# end

17. Configure OSPF on Router1

Task 28: Start OSPF

On Router1:

Router1> enable
Router1# configure terminal
Router1(config)# router ospf 1

Task 29: Advertise the Router-to-Router Network

Enter:

Router1(config-router)# network 10.0.0.0 0.0.0.3 area 0

Task 30: Advertise LAN 2

Enter:

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

Then:

Router1(config-router)# end

Complete Router1 OSPF configuration

Router1# configure terminal
Router1(config)# router ospf 1
Router1(config-router)# network 10.0.0.0 0.0.0.3 area 0
Router1(config-router)# network 192.168.2.0 0.0.0.255 area 0
Router1(config-router)# end

18. Understand the OSPF Network Command

Students often find this command confusing:

network 192.168.1.0 0.0.0.255 area 0

The second value is a wildcard mask, not a subnet mask.

Subnet mask

255.255.255.0

Wildcard mask

0.0.0.255

The wildcard mask is essentially the inverse of the subnet mask.

Similarly:

255.255.255.252

has the wildcard mask:

0.0.0.3

Therefore:

network 10.0.0.0 0.0.0.3 area 0

matches the interfaces belonging to the 10.0.0.0/30 network.


19. Task 31: Verify OSPF Neighbor Relationship

This is one of the most important commands in this experiment.

On Router0:

show ip ospf neighbor

You should see Router1 listed as an OSPF neighbor.

Similarly, on Router1:

show ip ospf neighbor

Router0 should appear as a neighbor.

The exact output varies with the router model and Packet Tracer version, but the neighbor should reach a stable state such as:

FULL

Important concept

An OSPF neighbor relationship means that the two routers have successfully established an OSPF relationship and can exchange routing information.


20. Task 32: Verify OSPF Configuration

On Router0:

show ip protocols

Students should identify:

Routing Protocol is "ospf 1"

and the networks participating in OSPF.

Repeat on Router1:

show ip protocols

21. Task 33: Examine the Routing Table After OSPF

On Router0:

show ip route

Router0 should now have an entry similar to:

O    192.168.2.0/24 [110/2] via 10.0.0.2

The exact cost can vary depending on the interfaces/router model.

The important observation is:

O

O means:

OSPF-learned route


22. Task 34: Examine Router1's Routing Table

On Router1:

show ip route

You should find a route similar to:

O    192.168.1.0/24 [110/2] via 10.0.0.1

Again:

O = OSPF

23. Compare the Routing Tables

Students should record the difference.

Before OSPF

Router0:

C  192.168.1.0/24
C  10.0.0.0/30

Router1:

C  10.0.0.0/30
C  192.168.2.0/24

After OSPF

Router0:

C  192.168.1.0/24
C  10.0.0.0/30
O  192.168.2.0/24

Router1:

C  10.0.0.0/30
C  192.168.2.0/24
O  192.168.1.0/24

This is the central observation of the experiment.


24. Task 35: Test Inter-LAN Connectivity

From PC0:

ping 192.168.2.10

The ping should now be successful.

The packet travels:

PC0
 ↓
Switch0
 ↓
Router0
 ↓
Router1
 ↓
Switch1
 ↓
PC2

25. Task 36: Test Reverse Connectivity

From PC2:

ping 192.168.1.10

Expected:

Successful


26. Task 37: Test PC1 to PC3

From PC1:

ping 192.168.2.11

Expected:

Successful


27. Task 38: Test PC3 to PC1

From PC3:

ping 192.168.1.11

Expected:

Successful


28. Connectivity Verification Table

Students should complete this table.

SourceDestinationCommand    Expected Result
PC0PC1ping 192.168.1.11    Success
PC2PC3ping 192.168.2.11    Success
PC0PC2ping 192.168.2.10    Success
PC2PC0ping 192.168.1.10    Success
PC1PC3ping 192.168.2.11    Success
PC3PC1ping 192.168.1.11    Success

29. Task 39: Use Tracert

From PC0:

tracert 192.168.2.10

Students should observe that packets pass through the two routers.

Conceptually:

PC0
 ↓
Router0
 ↓
Router1
 ↓
PC2

30. Task 40: Examine OSPF Neighbor Information

On Router0:

show ip ospf neighbor

Record:

Parameter    Observation
Neighbor Router ID            __________
Neighbor State__________
Neighbor IP Address__________
Local Interface__________

The neighbor state should normally reach:

FULL

31. Task 41: Examine OSPF Information

Use:

show ip ospf

This command provides information about:

  • OSPF process
  • Router ID
  • Areas
  • SPF calculations
  • Link-state information
  • Area information

Students should record:

OSPF Process ID: __________

Area: __________

Router ID: __________

32. Task 42: Examine OSPF Interfaces

Use:

show ip ospf interface

This command displays OSPF information associated with interfaces.

Students can observe:

  • OSPF area
  • OSPF process
  • Interface
  • Cost
  • Neighbor information
  • Network type

For a shorter output, depending on the Packet Tracer IOS version, try:

show ip ospf interface brief

33. Task 43: Understand OSPF Cost

OSPF uses cost as its routing metric.

In simplified terms:

Lower total OSPF cost is preferred.

For a path containing multiple interfaces:

Total Cost = Cost of Interface 1 + Cost of Interface 2 + ...

The exact cost values depend on the interface bandwidth and OSPF configuration.

This is different from RIP.

RIP

Uses:

Hop Count

OSPF

Uses:

Cost

34. Task 44: Compare RIP and OSPF

Students should complete this comparison.

FeatureRIPOSPF
Type    Distance Vector    Link State
Metric    Hop Count    Cost
Maximum usable hops    15    No 15-hop limitation
Route code    R    O
Algorithm    Distance-vector approach    SPF/Dijkstra
Convergence    Generally slower    Generally faster
Hierarchical areas    No    Yes
Area 0    No    Yes
Routing information    Periodically exchanged    Link-state information
Scalability    Limited    Better suited to larger networks

35. Task 45: Introduce an OSPF Configuration Error

This is an excellent troubleshooting activity.

On Router1, change the OSPF area for the LAN interface.

For example:

Router1(config)# router ospf 1
Router1(config-router)# no network 192.168.2.0 0.0.0.255 area 0
Router1(config-router)# network 192.168.2.0 0.0.0.255 area 1

Now check:

show ip route

and:

show ip ospf neighbor

Students should investigate what has changed.

Then restore the configuration:

Router1(config)# router ospf 1
Router1(config-router)# no network 192.168.2.0 0.0.0.255 area 1
Router1(config-router)# network 192.168.2.0 0.0.0.255 area 0
Router1(config-router)# end

36. Task 46: Disable the OSPF Interface

Another useful troubleshooting exercise:

On Router0:

configure terminal
interface gigabitEthernet 0/1
shutdown

Now execute:

show ip ospf neighbor

Observe the neighbor relationship.

Then:

show ip route

Try:

ping 192.168.2.10

The communication should fail because the path between the routers has been disabled.


37. Task 47: Enable the Interface Again

Enter:

interface gigabitEthernet 0/1
no shutdown
end

Wait for the OSPF neighbor relationship to be established again.

Verify:

show ip ospf neighbor

Then:

ping 192.168.2.10

The ping should succeed again.


38. Task 48: Save the Configuration

Once the experiment is working correctly, save the configuration.

On Router0:

copy running-config startup-config

On Router1:

copy running-config startup-config

39. Important OSPF Commands

PurposeCommand
Enter privileged mode    enable
Enter configuration mode    configure terminal
Start OSPF    router ospf 1
Advertise network    network NETWORK WILDCARD area 0
View routing table    show ip route
View OSPF neighbors    show ip ospf neighbor
View OSPF configuration    show ip protocols
View OSPF process    show ip ospf
View OSPF interfaces    show ip ospf interface
View interface summary    show ip interface brief
Test connectivity    ping IP-address
Trace packet path    tracert IP-address
Save configuration    copy running-config startup-config

40. Complete OSPF Configuration — Quick Reference

Router0

Router0> enable
Router0# configure terminal

Router0(config)# interface gigabitEthernet 0/0
Router0(config-if)# ip address 192.168.1.1 255.255.255.0
Router0(config-if)# no shutdown
Router0(config-if)# exit

Router0(config)# interface gigabitEthernet 0/1
Router0(config-if)# ip address 10.0.0.1 255.255.255.252
Router0(config-if)# no shutdown
Router0(config-if)# exit

Router0(config)# router ospf 1
Router0(config-router)# network 192.168.1.0 0.0.0.255 area 0
Router0(config-router)# network 10.0.0.0 0.0.0.3 area 0
Router0(config-router)# end

Router1

Router1> enable
Router1# configure terminal

Router1(config)# interface gigabitEthernet 0/0
Router1(config-if)# ip address 10.0.0.2 255.255.255.252
Router1(config-if)# no shutdown
Router1(config-if)# exit

Router1(config)# interface gigabitEthernet 0/1
Router1(config-if)# ip address 192.168.2.1 255.255.255.0
Router1(config-if)# no shutdown
Router1(config-if)# exit

Router1(config)# router ospf 1
Router1(config-router)# network 10.0.0.0 0.0.0.3 area 0
Router1(config-router)# network 192.168.2.0 0.0.0.255 area 0
Router1(config-router)# end

41. Observation Table

PC Configuration

PCIP AddressSubnet Mask    Default Gateway
PC0    192.168.1.10    255.255.255.0    192.168.1.1
PC1    192.168.1.11    255.255.255.0    192.168.1.1
PC2    192.168.2.10    255.255.255.0    192.168.2.1
PC3    192.168.2.11    255.255.255.0    192.168.2.1

Router Configuration

Router    Interface    IP AddressNetwork
Router0    G0/0    192.168.1.1    192.168.1.0/24
Router0    G0/1    10.0.0.1    10.0.0.0/30
Router1    G0/0    10.0.0.2    10.0.0.0/30
Router1    G0/1    192.168.2.1    192.168.2.0/24

42. OSPF Neighbor Observation

Students should record the output of:

show ip ospf neighbor
Router    Neighbor Router ID    Neighbor IP    State
Router0    __________    __________    __________
Router1    __________    __________        __________

Expected stable state:

FULL

43. OSPF Routing Table Observation

Router0

Destination Network    Route Type    Next Hop
192.168.1.0/24    Connected    —
10.0.0.0/30    Connected    —
192.168.2.0/24    OSPF    10.0.0.2

Router1

Destination NetworkRoute TypeNext Hop
10.0.0.0/30Connected—
192.168.2.0/24Connected—
192.168.1.0/24OSPF10.0.0.1

44. Result

Two separate LANs were successfully connected using two routers in Cisco Packet Tracer. OSPF dynamic routing was configured using Area 0, and an OSPF neighbor relationship was successfully established between the two routers. The routers dynamically learned the remote LAN networks, which were verified using the show ip route and show ip ospf neighbor commands. End-to-end connectivity between the two LANs was successfully verified using the ping command, and the packet path was examined using tracert.

Comments

Popular posts from this blog

Networks Lab PCCSL507 Semester 5 KTU CS 2024 Scheme - Dr Binu V P

Study of whois Command

Study and Use of ifconfig Command