/
Basic OSPF Configuration Example

Basic OSPF Configuration Example


Open Shortest Path First (OSPF) is a widely used routing protocol based on an algorithm that determines the shortest route for packets to reach a destination. This is opposed to the older Routing Information Protocol (RIP), which routes packets based on the fewest number of “hops” to the destination, meaning the number of routers a packet would have to traverse. 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 a basic OSPF configuration for Pica8 PICOS-based switches.


Fig.5-3 presents an example of configuring OSPF routing. Switch A and Switch B are located in the backbone area, 0.0.0.0. There are two non-backbone areas, 1.1.1.1 and 2.2.2.2.

Switch D will obtain the routes of networks 10.10.1.0/24, 10.10.3.0/24, and 10.10.9.0/24 through the LSAs sent from its neighbors. Switch C will obtain the routes of networks 10.10.1.0/24, 10.10.2.0/24, and 10.10.8.0/24 according to LSAs sent from its neighbors.

 
                     Figure 5-3   Basic OSPF Configuration 


Configuring Switch A

For switch A, configure 2 VLAN interfaces for networks 10.10.1.1/24 and 10.10.2.1/24. Also configure area 0.0.0.0, which includes network 10.10.1.1/24, and area 0.0.0.1, which includes network 10.10.2.1/24.

admin@XorPlus# set vlans vlan-id 2
admin@XorPlus# set vlans vlan-id 3
admin@XorPlus# set interface gigabit-ethernet ge-1/1/1 family ethernet-switching native-vlan-id 2
admin@XorPlus# set interface gigabit-ethernet ge-1/1/2 family ethernet-switching native-vlan-id 3
admin@XorPlus# set vlans vlan-id 2 l3-interface vlan-2
admin@XorPlus# set vlans vlan-id 3 l3-interface vlan-3
admin@XorPlus# set vlan-interface interface vlan-2 vif vlan-2 address 10.10.1.1 prefix-length 24
admin@XorPlus# set vlan-interface interface vlan-3 vif vlan-3 address 10.10.2.1 prefix-length 24
admin@XorPlus# commit
Waiting for merging configuration.
Commit OK.
Save done.
admin@XorPlus# set protocols ospf4 router-id 1.1.1.1
admin@XorPlus# set protocols ospf4 area 0.0.0.0 interface vlan-2 vif vlan-2 address 10.10.1.1
admin@XorPlus# set protocols ospf4 area 0.0.0.1 interface vlan-3 vif vlan-3 address 10.10.2.1
admin@XorPlus# commit
Waiting for merging configuration.
Commit OK.
Save done.
admin@XorPlus# 


Configuring Switch B

Configure 2 VLAN interfaces for networks 10.10.1.2/24 and 10.10.3.1/24. Then configure area 0.0.0.0, which includes network 10.10.1.2/24, and area 0.0.0.3, which includes network 10.10.3.1/24.

admin@XorPlus# set vlans vlan-id 2
admin@XorPlus# set vlans vlan-id 3
admin@XorPlus# set interface gigabit-ethernet ge-1/1/1 family ethernet-switching native-vlan-id 2
admin@XorPlus# set interface gigabit-ethernet ge-1/1/2 family ethernet-switching native-vlan-id 3
admin@XorPlus# set vlans vlan-id 2 l3-interface vlan-2
admin@XorPlus# set vlans vlan-id 3 l3-interface vlan-3
admin@XorPlus# set vlan-interface interface vlan-2 vif vlan-2 address 10.10.1.2 prefix-length 24
admin@XorPlus# set vlan-interface interface vlan-3 vif vlan-3 address 10.10.3.1 prefix-length 24
admin@XorPlus# commit
Waiting for merging configuration.
Commit OK.
Save done.
admin@XorPlus# set protocols ospf4 router-id 2.2.2.2
admin@XorPlus# set protocols ospf4 area 0.0.0.0 interface vlan-2 vif vlan-2 address 10.10.1.2
admin@XorPlus# set protocols ospf4 area 0.0.0.2 interface vlan-3 vif vlan-3 address 10.10.3.1
admin@XorPlus# commit
Waiting for merging configuration.
Commit OK.
Save done.
admin@XorPlus# 


Configuring Switch C

Configure just one OSPF interface in area 0.0.0.2.

admin@XorPlus# set vlans vlan-id 2
admin@XorPlus# set vlans vlan-id 3
admin@XorPlus# set interface gigabit-ethernet ge-1/1/1 family ethernet-switching native-vlan-id 2
admin@XorPlus# set interface gigabit-ethernet ge-1/1/2 family ethernet-switching native-vlan-id 3
admin@XorPlus# set vlans vlan-id 2 l3-interface vlan-2
admin@XorPlus# set vlans vlan-id 3 l3-interface vlan-3
admin@XorPlus# set vlan-interface interface vlan-2 vif vlan-2 address 10.10.3.2 prefix-length 24
admin@XorPlus# set vlan-interface interface vlan-3 vif vlan-3 address 10.10.9.1 prefix-length 24
admin@XorPlus# commit
Waiting for merging configuration.
Commit OK.
Save done.
admin@XorPlus# set protocols ospf4 router-id 3.3.3.3
admin@XorPlus# set protocols ospf4 area 0.0.0.2 interface vlan-2 vif vlan-2 address 10.10.3.2
admin@XorPlus# commit
Waiting for merging configuration.
Commit OK.
Save done.
admin@XorPlus# 


Configuring Switch D

Configure just one OSPF interface in area 0.0.0.1.

admin@XorPlus# set vlans vlan-id 2
admin@XorPlus# set vlans vlan-id 3
admin@XorPlus# set interface gigabit-ethernet ge-1/1/1 family ethernet-switching native-vlan-id 2
admin@XorPlus# set interface gigabit-ethernet ge-1/1/2 family ethernet-switching native-vlan-id 3
admin@XorPlus# set vlans vlan-id 2 l3-interface vlan-2
admin@XorPlus# set vlans vlan-id 3 l3-interface vlan-3
admin@XorPlus# set vlan-interface interface vlan-2 vif vlan-2 address 10.10.2.2 prefix-length 24
admin@XorPlus# set vlan-interface interface vlan-3 vif vlan-3 address 10.10.8.1 prefix-length 24
admin@XorPlus# commit
Waiting for merging configuration.
Commit OK.
Save done.
admin@XorPlus# set protocols ospf4 router-id 4.4.4.4
admin@XorPlus# set protocols ospf4 area 0.0.0.1 interface vlan-2 vif vlan-2 address 10.10.2.2
admin@XorPlus# commit
Waiting for merging configuration.
Commit OK.
Save done.
admin@XorPlus# 


Verifying the OSPF configuration

You can verify the OSPF configuration of a switch by checking its OSPF neighbor.
Below, switch A has two OSPF neighbor interfaces, 10.10.1.2 and 10.10.2.2.

admin@XorPlus# run show ospf4 neighbor 
Address Interface State Router ID Pri Dead
--------------- --------------------- -------- --------------- ----- ----
10.10.1.2vlan-2/vlan-2 Full 2.2.2.2 1 32 
10.10.2.2vlan-3/vlan-3 Full 4.4.4.4 1 32 
 
Then check the OSPF database as shown below: 
admin@XorPlus# run show ospf4 database 
OSPF link state database, Area 0.0.0.0
Type ID Adv Rtr Seq Age Opt Cksum Len
------- ---------------- --------------- ---------- ---- — ------ —
Router *1.1.1.1 1.1.1.1 0x8000025a 394 0x2 0xf2bb 48 
Network *10.10.1.1 1.1.1.1 0x80000180 394 0x2 0xc0b9 32 
Network *10.10.2.1 1.1.1.1 0x80000180 394 0x2 0xc0b9 32
Router 2.2.2.2 2.2.2.2 0x8000023e 339 0x2 0x3024 36 
Network 10.10.3.1 2.2.2.2 0x80000180 394 0x2 0xc0b9 32
Router 3.3.3.33.3.3.3 0x8000023e 339 0x2 0x3024 36
Network 10.10.9.1 3.3.3.3 0x80000180 394 0x2 0xc0b9 32
Router 4.4.4.44.4.4.4 0x8000023e 339 0x2 0x3024 36
Network 10.10.8.1 4.4.4.4 0x80000180 394 0x2 0xc0b9 32 
OSPF link state database, Area 0.0.0.2
Type ID Adv Rtr Seq Age Opt Cksum Len
------- ---------------- --------------- ---------- ---- — ------ —
Router *1.1.1.1 1.1.1.1 0x8000025a 394 0x2 0xf2bb 48 
Network *10.10.1.1 1.1.1.1 0x80000180 394 0x2 0xc0b9 32 
Network *10.10.2.1 1.1.1.1 0x80000180 394 0x2 0xc0b9 32
Router 2.2.2.2 2.2.2.2 0x8000023e 339 0x2 0x3024 36 
Network 10.10.3.1 2.2.2.2 0x80000180 394 0x2 0xc0b9 32
Router 3.3.3.33.3.3.3 0x8000023e 339 0x2 0x3024 36 
Network 10.10.9.1 3.3.3.3 0x80000180 394 0x2 0xc0b9 32
Router 4.4.4.44.4.4.4 0x8000023e 339 0x2 0x3024 36
Network 10.10.8.1 4.4.4.4 0x80000180 394 0x2 0xc0b9 32 
Finally, you can check the OSPF route in the RIB of switch A. 
admin@XorPlus#
admin@XorPlus# run show route table ipv4 unicast osfp 
10.10.3.0/24 [ospf(110)/2]
> to 10.10.1.2 via vlan-2/vlan-2 

Copyright © 2025 Pica8 Inc. All Rights Reserved.