Basic OSPF Configuration Example


Open Shortest Path First (OSPF) is a widely used routing protocol based on the Dijkstra's Shortest Path First algorithm that determines the shortest path for packets to reach a destination. This is opposed to the older Routing Information Protocol (RIP) in which best path is based on the fewest number of “hops” to the destination, meaning that a path in which the packet would have to traverse the fewest number of routers is considered the best one. OSPF is an interior gateway protocol (IGP) intended for use in a single routing domain, or autonomous system (AS). It is a dynamic routing protocol that, like RIP, changes routing tables whenever the network topology changes. It determines the shortest path through a network based on the “cost” of the route, meaning it considers the amount of available bandwidth, delay and load on different network segments.  This document describes an example of basic OSPF configuration for PICOS-based switches.


Fig.5-3 presents an example topology for configuring OSPF routing. There are two areas configured in this network, Router 1 has two interfaces both in area 1 whereas Router 2 and 3 have two interfaces each, with one interface each in area 0 and area1.

After OSPF is configured on the four routers, the routers will send LSAs to each and hence will have routes to all the subnets in the network. Router1 will have routes to all the connected subnets of Router2, Router3 and Router4. Similarly, all the other routers will have access to all the other subnets configured for OSPF. The detailed configuration of each router is shown below.


                             Figure 5-3   Basic OSPF Configuration 



Configuring Router 1

Configure 2 VLAN interfaces for networks 10.1.1.0/24 and 20.1.1.0/24. There is only one area configured on Router 1, area 1 which include networks 10.1.1.0/24 and 20.1.1.0/24.

admin@router1# set interface gigabit-ethernet ge-1/1/1 family ethernet-switching native-vlan-id 10
admin@router1# set interface gigabit-ethernet ge-1/1/2 family ethernet-switching native-vlan-id 20
admin@router1# set protocols ospf router-id 1.1.1.1
admin@router1# set protocols ospf network 10.1.1.0/24 area 1
admin@router1# set protocols ospf network 20.1.1.0/24 area 1
admin@router1# set protocols ospf network 1.1.1.1/32 area 1
admin@router1# set l3-interface loopback lo address 1.1.1.1 prefix-length 32
admin@router1# set l3-interface vlan-interface vlan10 address 10.1.1.1 prefix-length 24
admin@router1# set l3-interface vlan-interface vlan20 address 20.1.1.1 prefix-length 24
admin@router1# set vlans vlan-id 10 l3-interface "vlan10"
admin@router1# set vlans vlan-id 20 l3-interface "vlan20"


Configuring Route 2

On Router 2, we will configure the router ID as 1.1.1.1 and configure two VLAN interfaces. For 10.1.1.1.0/24 we will configure interface vlan10 in area 1 and for network 30.1.1.0/24 we will configure interface vlan30 in area 0.

admin@router2# set interface gigabit-ethernet ge-1/1/3 family ethernet-switching native-vlan-id 10
admin@router2# set interface gigabit-ethernet ge-1/1/5 family ethernet-switching native-vlan-id 30
admin@router2# set protocols ospf router-id 2.2.2.2
admin@router2# set protocols ospf network 10.1.1.0/24 area 1
admin@router2# set protocols ospf network 30.1.1.0/24 area 0
admin@router2# set l3-interface loopback lo address 2.2.2.2 prefix-length 32
admin@router2# set l3-interface vlan-interface vlan10 address 10.1.1.2 prefix-length 24
admin@router2# set l3-interface vlan-interface vlan30 address 30.1.1.1 prefix-length 24
admin@router2# set vlans vlan-id 10 l3-interface "vlan10"
admin@router2# set vlans vlan-id 30 l3-interface "vlan30"


Configuring Router 3

On Router 3 we will configure the router ID as 3.3.3.3 and two VLAN interfaces.  Interface vlan10 for network 10.1.1.0/24 is added to area 1 and VLAN interface vlan30 for network 30.1.1.0/24 is added to area 0.

admin@router3# set interface gigabit-ethernet te-1/1/3 family ethernet-switching native-vlan-id 20
admin@router3# set interface gigabit-ethernet te-1/1/3 auto-speeds 1000
admin@router3# set interface gigabit-ethernet te-1/1/5 family ethernet-switching native-vlan-id 40
admin@router3# set interface gigabit-ethernet te-1/1/5 auto-speeds 1000
admin@router3# set protocols spanning-tree enable false
admin@router3# set protocols ospf router-id 3.3.3.3
admin@router3# set protocols ospf network 20.1.1.0/24 area 1
admin@router3# set protocols ospf network 40.1.1.0/24 area 0
admin@router3# set l3-interface vlan-interface vlan20 address 20.1.1.2 prefix-length 24
admin@router3# set l3-interface vlan-interface vlan40 address 40.1.1.1 prefix-length 24
admin@router3# set vlans vlan-id 20 l3-interface "vlan20"
admin@router3# set vlans vlan-id 40 l3-interface "vlan40"
admin@router3# commit
Commit OK.
Save done.


Configuring Router 4

The router ID on Router 4 is configured as 4.4.4.4 and two VLAN interfaces both of which are in area 0. VLAN interface vlan30 for network 30.1.1.0/24 is in area 0 and VLAN interface vlan40 for network 40.1.1.0/24 also belonging to area 0.

admin@router4# set interface gigabit-ethernet te-1/1/1 family ethernet-switching native-vlan-id 30
admin@router4# set interface gigabit-ethernet te-1/1/2 family ethernet-switching native-vlan-id 40
admin@router4# set protocols ospf router-id 4.4.4.4
admin@router4# set protocols ospf network 30.1.1.0/24 area 0
admin@router4# set protocols ospf network 40.1.1.0/24 area 0
admin@router4# set protocols ospf network 4.4.4.4/32 area 0
admin@router4# set protocols ospf redistribute static
admin@router4# set l3-interface loopback lo address 4.4.4.4 prefix-length 32
admin@router4# set l3-interface vlan-interface vlan30 address 30.1.1.2 prefix-length 24
admin@router4# set l3-interface vlan-interface vlan40 address 40.1.1.2 prefix-length 24
admin@router4# set vlans vlan-id 40 l3-interface vlan40
admin@router4# set vlans vlan-id 30 l3-interface vlan30
Commit OK.
Save done.


Verifying the OSPF configuration

We can verify the OSPF configuration of a switch by checking its OSPF neighbors by running the command run show ospf neighbor.
Below is the command output on Router 1. As we can see Router 1 has established neighbor relationship with Router 2 (router ID 2.2.2.2) and Router 3 (router ID 3.3.3.3).

admin@router1# run show ospf neighbor
Neighbor ID     Pri State           Dead Time Address         Interface                        RXmtL RqstL DBsmL
2.2.2.2           1 Full/DR           35.852s 10.1.1.2        vlan.2:10.1.1.1                      0     0     0
3.3.3.3           1 Full/DR           31.187s 20.1.1.2        vlan.3:20.1.1.1                      0     0     0

Now check the OSPF database on Router 1 by running the command run show ospf database.

admin@router1# run show ospf database
OSPF Router with ID (1.1.1.1)

                Router Link States (Area 0.0.0.1)

Link ID         ADV Router      Age  Seq#       CkSum  Link count
1.1.1.1         1.1.1.1         1528 0x8000001e 0xe83f 4
2.2.2.2         2.2.2.2         1548 0x8000000f 0xcd41 1
3.3.3.3         3.3.3.3         1534 0x8000000f 0x3cb4 1

                Net Link States (Area 0.0.0.1)

Link ID         ADV Router      Age  Seq#       CkSum
10.1.1.2        2.2.2.2         1578 0x80000009 0x0e22
20.1.1.2        3.3.3.3         1524 0x80000009 0x9f7e

                Summary Link States (Area 0.0.0.1)

Link ID         ADV Router      Age  Seq#       CkSum  Route
4.4.4.4         2.2.2.2         1328 0x80000009 0xcb30 4.4.4.4/32
4.4.4.4         3.3.3.3         1254 0x80000009 0xad4a 4.4.4.4/32
30.1.1.0        2.2.2.2         1288 0x8000000a 0xe23f 30.1.1.0/24
30.1.1.0        3.3.3.3         1334 0x80000009 0x2be9 30.1.1.0/24
40.1.1.0        2.2.2.2         1378 0x80000009 0xc648 40.1.1.0/24
40.1.1.0        3.3.3.3         1244 0x80000009 0x44d0 40.1.1.0/24

To check the IPv4 route table on Router 1, run the command run show route ipv4.

admin@router1# run show route ipv4
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

K>* 0.0.0.0/0 [0/0] via 10.10.51.1, eth0, 00:28:55
O   1.1.1.1/32 [110/10] via 0.0.0.0, loopback onlink, weight 1, 00:28:54
C>* 1.1.1.1/32 is directly connected, loopback, 00:28:55
O>* 4.4.4.4/32 [110/30] via 10.1.1.2, vlan10, weight 1, 00:21:34
  *                     via 20.1.1.2, vlan20, weight 1, 00:21:34
O   10.1.1.0/24 [110/10] is directly connected, vlan10, weight 1, 00:27:02
C>* 10.1.1.0/24 is directly connected, vlan10, 00:27:46
C>* 10.10.51.0/24 is directly connected, eth0, 00:28:55
O   20.1.1.0/24 [110/10] is directly connected, vlan20, weight 1, 00:24:56
C>* 20.1.1.0/24 is directly connected, vlan20, 00:25:56
O>* 30.1.1.0/24 [110/20] via 10.1.1.2, vlan10, weight 1, 00:21:37
O>* 40.1.1.0/24 [110/20] via 20.1.1.2, vlan20, weight 1, 00:22:26

Copyright © 2024 Pica8 Inc. All Rights Reserved.