OSPF HowTo

About

This document provides a basic OSPF use-case, and how it is configured using the CLI.

For an overview of all available configuration settings for OSPF refer to the configuration guide:

Introduction

In Figure 1 below a simple example of a network is presented, with four routers and a number of networks connected to them. In order to ensure that the different networks can reach each other we want to utilize OSPF on the routers to dynamically set up the necessary routes.

   Net-A                               Net-B
  .--.-.                              .--.-.
 ( (    )__                          ( (    )__
(_,  \ ) ,_)                        (_,  \ ) ,_)
  '-'--`--'                           '-'--`--'
     |                                   |
     | 10.0.11.0/24                      | 10.0.14.0/24
   .1|                                 .1|
.----+-----.                        .----+-----.
|          |.1                    .2|          |
| Router-A +------------------------+ Router-B |
|          |      10.0.1.0/24       |          |
'----+-----'                        '----+-----'
   .2|                                 .1|
     | 10.0.2.0/24                       | 10.0.4.0/24
   .1|                                 .2|
.----+-----.                        .----+-----.
|          |.2                    .1|          |
| Router-C +------------------------+ Router-D |
|          |      10.0.3.0/24       |          |
'----+-----'                        '----+-----'
   .1|                                 .1|
     | 10.0.12.0/24                      | 10.0.13.0/24
     |                                   |
  .--.-.                              .--.-.
 ( (    )__                          ( (    )__
(_,  \ ) ,_)                        (_,  \ ) ,_)
  '-'--`--'                           '-'--`--'
   Net-C                               Net-D

Figure 1: Example OSPF network with IP addresses and subnets.

In a simple case like this, configuring an OSPF network is not something that is difficult. Essentially the only thing that needs to be configured is the networks that should be served by OSPF on each of the routers. In this case, for instance, Router-A would be configured to include and announce all its subnets in the OSPF domain (10.0.11.0/24, 10.0.1.0/24, 10.0.2.0/24). The other routers in the setup would be configured in the same manner.

Configuration

The individual routers should be configured to include all their network connections in the OSPF domain. The example presented in this use-case is a “flat” OSPF network, i.e. only one area is utilized, the backbone (area 0.0.0.0).

When configuring OSPF it is very important that the OSPF router-id is unique to each individual router part of the OSPF network. It is common practice to set the router-id to one of the IP addresses assigned to the router.

Note

In this example we do not explicitly configure the router-id, we let it be assigned automatically. In this case the router-id will be assigned the IP address of one of the router’s interfaces (the one with the highest IP address). For example in this case, Router-A will be assigned a router-id of 10.0.11.1, since it is the highest IP address if its interfaces.

Router A

Configure OSPF on Router-A to announce all its network connections as part of the OSPF domain:

Router-A:/#> configure
Router-A:/config/#> router
Router-A:/config/router/#> ospf
Router-A:/config/router/ospf/#> network 10.0.1.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-A:/config/router/ospf/#> network 10.0.2.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-A:/config/router/ospf/#> network 10.0.11.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-A:/config/router/ospf/#> leave
Router-A:/#>

Router B

Configure OSPF on Router-B to announce all its network connections as part of the OSPF domain:

Router-B:/#> configure
Router-B:/config/#> router
Router-B:/config/router/#> ospf
Router-B:/config/router/ospf/#> network 10.0.1.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-B:/config/router/ospf/#> network 10.0.4.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-B:/config/router/ospf/#> network 10.0.14.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-B:/config/router/ospf/#> leave
Router-B:/#>

Router C

Configure OSPF on Router-C to announce all its network connections as part of the OSPF domain:

Router-C:/#> configure
Router-C:/config/#> router
Router-C:/config/router/#> ospf
Router-C:/config/router/ospf/#> network 10.0.2.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-C:/config/router/ospf/#> network 10.0.3.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-C:/config/router/ospf/#> network 10.0.12.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-C:/config/router/ospf/#> leave
Router-C:/#>

Router D

Configure OSPF on Router-D to announce all its network connections as part of the OSPF domain:

Router-D:/#> configure
Router-D:/config/#> router
Router-D:/config/router/#> ospf
Router-D:/config/router/ospf/#> network 10.0.3.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-D:/config/router/ospf/#> network 10.0.4.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-D:/config/router/ospf/#> network 10.0.13.0/24
Defaulting to OSPF backbone, area 0.0.0.0
Router-D:/config/router/ospf/#> leave
Router-D:/#>

Status

There are a few different ways we can observe the status of our OSPF network. The most important thing is that OSPF learns the routes. We can check the routes learnt by OSPF in the following way:

Router-A:/#> show ip ospf route
============ OSPF network routing table ============
N    10.0.1.0/24           [10] area: 0.0.0.0
                           directly attached to vlan1
N    10.0.2.0/24           [10] area: 0.0.0.0
                           directly attached to vlan2
N    10.0.3.0/24           [20] area: 0.0.0.0
                           via 10.0.2.1, vlan2
N    10.0.4.0/24           [20] area: 0.0.0.0
                           via 10.0.1.2, vlan1
N    10.0.11.0/24          [10] area: 0.0.0.0
                           directly attached to vlan3
N    10.0.12.0/24          [20] area: 0.0.0.0
                           via 10.0.2.1, vlan2
N    10.0.13.0/24          [30] area: 0.0.0.0
                           via 10.0.1.2, vlan1
                           via 10.0.2.1, vlan2
N    10.0.14.0/24          [20] area: 0.0.0.0
                           via 10.0.1.2, vlan1

============ OSPF router routing table =============

============ OSPF external routing table ===========

We can also check routes in the following manner, where routes learnt by OSPF is signified by O:

Router-A:/#> show ip route
S - Static | C - Connected | K - Kernel route  | > - Selected route
O - OSPF   | R - RIP       | [Distance/Metric] | * - FIB route

O   10.0.1.0/24 [110/10] is directly connected, vlan1, 01:40:21
C>* 10.0.1.0/24 is directly connected, vlan1
O   10.0.2.0/24 [110/10] is directly connected, vlan2, 01:40:21
C>* 10.0.2.0/24 is directly connected, vlan2
O>* 10.0.3.0/24 [110/20] via 10.0.2.1, vlan2, 01:39:41
O>* 10.0.4.0/24 [110/20] via 10.0.1.2, vlan1, 01:35:46
O   10.0.11.0/24 [110/10] is directly connected, vlan3, 01:40:21
C>* 10.0.11.0/24 is directly connected, vlan3
O>* 10.0.12.0/24 [110/20] via 10.0.2.1, vlan2, 01:39:41
O>* 10.0.13.0/24 [110/30] via 10.0.1.2, vlan1, 01:35:46
  *                       via 10.0.2.1, vlan2, 01:35:46
O>* 10.0.14.0/24 [110/20] via 10.0.1.2, vlan1, 01:35:46