Multiple OSPF Instances
By using multiple OSPF instances, OSPF routes can be segregated, based on their instance number. Routes of one instance are stored differently from routes of another instance running in the same router.
To configure multiple OSPF instances, perform the following procedures referring to the topology diagram below:
1. Enable OSPF on an interface.
2. Enable multiple instances.
3. Configure redistribution among multiple instances.
Note: Optionally, redistribution can be configured with the metric, type or route-map options.
Topology
.

Figure 8-72: Multiple OSPF Instances
Enable Multiple OSPF Instances on a Router
In this example, routers R1, R2, and R3 are in Area 0, and all run OSPF.
R1
(config)#interface eth1 | Enter interface mode for eth1. |
(config-if)#ip address 2.2.2.2/24 | Specify the IP address of the interface. |
(config-if)#no shutdown | Activate the interface. |
(config-if)#exit | Exit interface mode. |
(config)#router ospf 10 | Configure an OSPF instance with an instance ID of 10. |
(config-router)#router-id 5.5.5.5 | Configure the router ID to use on this instance. |
(config-router)#network 2.2.2.0/24 area 0 | Advertise the network with the area ID. |
(config-router)#commit | Commit the candidate configuration to the running configuration. |
R2
(config)#interface eth1 | Enter interface mode for eth1. |
(config-if)#ip address 2.2.2.3/24 | Specify the IP address of the interface. |
(config-if)#no shutdown | Activate the interface. |
(config-if)#exit | Exit interface mode. |
(config)#router ospf 10 | Configure an OSPF instance with an instance ID of 10. |
(config-router)#router-id 6.6.6.6 | Configure the router ID to use on this instance. |
(config-router)#network 2.2.2.0/24 area 0 | Advertise the network with the area ID. |
(config-router)#exit | Exit router mode. |
(config)#interface eth2 | Enter interface mode for eth2. |
(config-if)#ip address 4.4.4.4/24 | Configure the IP address. |
(config-if)#no shutdown | Activate the interface. |
(config-if)#exit | Exit interface mode. |
(config)#router ospf 15 | Configure an OSPF instance with an instance ID of 15. |
(config-router)#router-id 8.8.8.8 | Configure the router ID to use on this instance. |
(config-router)#network 4.4.4.0/24 area 0 | Advertise the network with the area ID. |
(config-router)#commit | Commit the candidate configuration to the running configuration. |
R3
(config)#interface eth1 | Enter interface mode for eth1. |
(config-if)#ip address 4.4.4.5/24 | Configure the IP address. |
(config-if)#no shutdown | Activate the interface. |
(config-if)#exit | Exit interface mode. |
(config)#router ospf 15 | Configure an OSPF instance with an instance ID of 15. |
(config-router)#router-id 7.7.7.7 | Configure the router ID to use on this instance. |
(config-router)#network 4.4.4.0/24 area 0 | Advertise the network with the area ID. |
(config-router)#commit | Commit the candidate configuration to the running configuration. |
Validation
R1
R1#sh running-config
!
no service password-encryption
!
hostname R1
!
logging monitor 7
!
ip vrf management
!
ip domain-lookup
!
ip pim register-rp-reachability
!
interface lo
mtu 65536
ip address 127.0.0.1/8
ipv6 address ::1/128
!
interface eth0
ip address 10.12.26.88/24
!
interface eth1
ip address 2.2.2.2/24
!
interface eth2
ip address 10.10.11.10/24
!
interface eth3
!
interface eth4
!
interface eth5
!
interface eth6
!
interface eth7
!
router ospf 10
ospf router-id 5.5.5.5
network 2.2.2.0/24 area 0.0.0.0
!
line con 0
login
line vty 0 39
login
!
end
R1#sh ip ospf neighbor
Total number of full neighbors: 1
OSPF process 10 VRF(default):
Neighbor ID Pri State Dead Time Address Interface Instance ID
6.6.6.6 1 Full/Backup 00:00:39 2.2.2.3 eth1 0
R1#sh ip ospf route
OSPF process 10:
Codes: C - connected, D - Discard, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
C 2.2.2.0/24 [1] is directly connected, eth1, Area 0.0.0.0
R2
R2#sh running-config
!
no service password-encryption
!
hostname R2
!
logging monitor 7
!
ip vrf management
!
ip domain-lookup
!
ip pim register-rp-reachability
!
interface lo
mtu 65536
ip address 127.0.0.1/8
ipv6 address ::1/128
!
interface eth0
ip address 10.12.26.89/24
!
interface eth1
ip address 2.2.2.3/24
!
interface eth2
ip address 4.4.4.4/24
!
interface eth3
!
interface eth4
!
interface eth5
!
interface eth6
!
router ospf 10
ospf router-id 6.6.6.6
network 2.2.2.0/24 area 0.0.0.0
!
router ospf 15
ospf router-id 8.8.8.8
network 4.4.4.0/24 area 0.0.0.0
no capability cspf
!
line con 0
login
line vty 0 39
login
!
end
R2#sh ip ospf neighbor
Total number of full neighbors: 1
OSPF process 10 VRF(default):
Neighbor ID Pri State Dead Time Address Interface Instance ID
5.5.5.5 1 Full/DR 00:00:33 2.2.2.2 eth1 0
Total number of full neighbors: 1
OSPF process 15 VRF(default):
Neighbor ID Pri State Dead Time Address Interface Instance ID
7.7.7.7 1 Full/Backup 00:00:31 4.4.4.5 eth2 0
R2#sh ip ospf route
OSPF process 10:
Codes: C - connected, D - Discard, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
C 2.2.2.0/24 [1] is directly connected, eth1, Area 0.0.0.0
OSPF process 15:
Codes: C - connected, D - Discard, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
C 4.4.4.0/24 [1] is directly connected, eth2, Area 0.0.0.0
R3
R3#sh running-config
!
no service password-encryption
!
hostname R3
!
logging monitor 7
!
ip vrf management
!
ip domain-lookup
!
ip pim register-rp-reachability
!
interface lo
mtu 65536
ip address 127.0.0.1/8
ipv6 address ::1/128
!
interface eth0
ip address 10.12.26.90/24
!
interface eth1
ip address 4.4.4.5/24
!
interface eth2
ip address 10.10.13.10/24
!
interface eth3
!
interface eth4
!
interface eth5
!
interface eth6
!
router ospf 15
ospf router-id 7.7.7.7
network 4.4.4.0/24 area 0.0.0.0
!
line con 0
login
line vty 0 39
login
!
end
R3#sh ip ospf neighbor
Total number of full neighbors: 1
OSPF process 15 VRF(default):
Neighbor ID Pri State Dead Time Address Interface Instance ID
8.8.8.8 1 Full/DR 00:00:30 4.4.4.4 eth1 0
Redistribute among Multiple Instances
In this example, routes of one instance are redistributed to another instance to enable ping from R1 to R3 or vice versa; and R2 redistributes routes from one instance to another.
R2
(config)#router ospf 15 | Configure an OSPF instance with instance ID 15. |
(config-router)#router-id 8.8.8.8 | Configure the router ID. |
(config-router)#redistribute ospf 10 | Redistribute instance 10 routes. |
(config-router)#redistribute connected | Redistribute connected routes to instance 15. |
(config-router)#exit | Exit Router mode, and return to Configure mode. |
(config)#router ospf 10 | Configure an OSPF instance with instance ID 10. |
(config-router)#router-id 6.6.6.6 | Configure the router ID. |
(config-router)#redistribute ospf 15 | Redistribute instance 15 routes. |
(config-router)#redistribute connected | Redistribute connected routes to instance 10. |
(config-router)#commit | Commit the candidate configuration to the running configuration. |
Redistribute with the Metric Option
In this example, on R3, R1 and R2 have each other’s routes with a metric of 100.
R2
(config)#router ospf 15 | Configure an OSPF instance with instance ID 15. |
(config-router)#router-id 8.8.8.8 | Configure the router ID. |
(config-router)#redistribute ospf 10 metric 100 | Redistribute instance 10 routes with metric 100. |
(config-router)#redistribute connected | Redistribute connected routes to instance 15. |
(config-router)#exit | Exit Router mode, and return to Configure mode. |
(config)#router ospf 10 | Configure an OSPF instance with instance ID 10. |
(config-router)#router-id 6.6.6.6 | Configure the router ID. |
(config-router)#redistribute ospf 15 metric 100 | Redistribute instance 15 routes with metric 100. |
(config-router)#redistribute connected | Redistribute connected routes to instance 10. |
(config-router)#commit | Commit the candidate configuration to the running configuration. |
Redistribute with the Type Option
In this example, on R3, R1 has R3 routes as type 2, and R2 has R1 routes as type 1.
R2
(config)#router ospf 15 | Configure an OSPF instance with instance ID 15. |
(config-router)#router-id 8.8.8.8 | Configure the router ID. |
(config-router)#redistribute ospf 10 metric-type 1 | Redistribute instance 10 routes with metric-type 1. |
(config-router)#redistribute connected | Redistribute connected routes to instance 15. |
(config-router)#exit | Exit Router mode, and return to Configure mode. |
(config)#router ospf 10 | Configure an OSPF instance with instance ID 10. |
(config-router)#router-id 6.6.6.6 | Configure the router ID. |
(config-router)#redistribute ospf 15 metric-type 2 | Redistribute instance 15 routes with type 2. |
(config-router)#redistribute connected | Redistribute connected routes to instance 10. |
(config-router)#commit | Commit the candidate configuration to the running configuration. |
Redistribute with the Route-Map Option
R2
(config)#route-map 1 permit 10 | Enter route-map mode, specifying route-map ID. |
(config-route-map)#set metric 100 | Set metric value. |
(config-route-map)#set metric-type type-2 | Set metric-type. |
(config-route-map)#exit | Exit route-map mode. |
(config)#route-map 2 permit 10 | Enter route-map mode, specifying route-map ID. |
(config-route-map)#set metric 200 | Set metric value. |
(config-route-map)#set metric-type type-1 | Set metric-type. |
(config-route-map)#exit | Exit route-map mode. |
(config)#router ospf 15 | Configure an OSPF instance with instance ID 15. |
(config-router)#router-id 8.8.8.8 | Configure the router ID. |
(config-router)#redistribute ospf 10 route-map 1 | Redistribute instance 10 routes with route map 1. |
(config-router)#redistribute connected | Redistribute connected routes to instance 15. |
(config-router)#exit | Exit Router mode, and return to Configure mode. |
(config)#router ospf 10 | Configure an OSPF instance with instance ID 10. |
(config-router)#router-id 6.6.6.6 | Configure the router ID. |
(config-router)#redistribute ospf 15 route-map 2 | Redistribute instance 15 routes with route map 2. |
(config-router)#redistribute connected | Redistribute connected routes to instance 10. |
(config-router)#commit | Commit the candidate configuration to the running configuration. |
Validation
R1#show ip ospf neighbor
Total number of full neighbors: 1
OSPF process 10 VRF(default):
Neighbor ID Pri State Dead Time Address Interface Instance ID
6.6.6.6 1 Full/DR 00:00:39 2.2.2.3 eth1 0
R2#show ip ospf neighbor
Total number of full neighbors: 1
OSPF process 10 VRF(default):
Neighbor ID Pri State Dead Time Address Interface Instance ID
5.5.5.5 1 Full/Backup 00:00:35 2.2.2.2 eth1 0
Total number of full neighbors: 1
OSPF process 15 VRF(default):
Neighbor ID Pri State Dead Time Address Interface Instance ID
7.7.7.7 1 Full/Backup 00:00:36 4.4.4.5 eth2 0
R3#show ip ospf neighbor
Total number of full neighbors: 1
OSPF process 15 VRF(default):
Neighbor ID Pri State Dead Time Address Interface Instance ID
8.8.8.8 1 Full/DR 00:00:40 4.4.4.4 eth2 0
R1#show ip route
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,
ia - IS-IS inter area, E - EVPN,
v - vrf leaked
* - candidate default
IP Route Table for VRF "default"
C 2.2.2.0/24 is directly connected, eth1, 00:08:40
O E1 4.4.4.0/24 [110/201] via 2.2.2.3, eth1, 00:01:18
C 5.5.5.5/32 is directly connected, lo, 00:08:41
O E2 6.6.6.6/32 [110/20] via 2.2.2.3, eth1, 00:01:10
O E2 8.8.8.8/32 [110/20] via 2.2.2.3, eth1, 00:01:10
C 127.0.0.0/8 is directly connected, lo, 00:08:44
C 192.168.20.0/24 is directly connected, eth0, 00:08:40
Gateway of last resort is not set
R2#show ip route
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,
ia - IS-IS inter area, E - EVPN,
v - vrf leaked
* - candidate default
IP Route Table for VRF "default"
C 2.2.2.0/24 is directly connected, eth1, 5d00h02m
C 4.4.4.0/24 is directly connected, eth2, 5d00h02m
C 6.6.6.6/32 is directly connected, lo, 4d23h59m
C 8.8.8.8/32 is directly connected, lo, 4d23h59m
C 127.0.0.0/8 is directly connected, lo, 5d00h09m
C 192.168.20.0/24 is directly connected, eth0, 5d00h08m
Gateway of last resort is not set
R3#show ip route
Codes: K - kernel, C - connected, S - static, R - RIP, B - BGP
O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,
ia - IS-IS inter area, E - EVPN,
v - vrf leaked
* - candidate default
IP Route Table for VRF "default"
O E2 2.2.2.0/24 [110/20] via 4.4.4.4, eth2, 00:02:45
C 4.4.4.0/24 is directly connected, eth2, 00:07:12
C 5.5.5.5/32 is directly connected, lo, 00:16:35
O E2 6.6.6.6/32 [110/20] via 4.4.4.4, eth2, 00:02:45
O E2 8.8.8.8/32 [110/20] via 4.4.4.4, eth2, 00:02:45
C 127.0.0.0/8 is directly connected, lo, 00:16:39
C 192.168.20.0/24 is directly connected, eth0, 00:15:36
Gateway of last resort is not set
#show ip ospf route
OSPF process 100:
Codes: C - connected, D - Discard, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
C 10.10.9.0/24 [1] is directly connected, eth2, Area 0.0.0.0
C 10.10.10.0/24 [1] is directly connected, eth3, Area 0.0.0.0
O 10.10.11.0/24 [101] via 10.10.10.11, eth3, Area 0.0.0.0
C 10.10.12.0/24 [1] is directly connected, eth1, Area 0.0.0.0
O 10.10.13.0/24 [102] via 10.10.10.11, eth3, Area 0.0.0.0
O 10.10.14.0/24 [102] via 10.10.10.11, eth3, Area 0.0.0.0
R2#show route-map
route-map 1, permit, sequence 10
Match clauses:
Set clauses:
metric 100
metric-type type-2
route-map 2, permit, sequence 10
Match clauses:
Set clauses:
metric 200
metric-type type-1
R1#show ip ospf route
OSPF process 10:
Codes: C - connected, D - Discard, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
C 2.2.2.0/24 [1] is directly connected, eth1, Area 0.0.0.0
E1 4.4.4.0/24 [201] via 2.2.2.3, eth1
E2 6.6.6.6/32 [1/20] via 2.2.2.3, eth1
E2 8.8.8.8/32 [1/20] via 2.2.2.3, eth1
E2 192.168.20.0/24 [1/20] via 2.2.2.3, eth1
R2#show ip ospf route
OSPF process 10:
Codes: C - connected, D - Discard, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
C 2.2.2.0/24 [1] is directly connected, eth1, Area 0.0.0.0
OSPF process 15:
Codes: C - connected, D - Discard, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
C 4.4.4.0/24 [1] is directly connected, eth2, Area 0.0.0.0
R3#show ip ospf route
OSPF process 15:
Codes: C - connected, D - Discard, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
E2 2.2.2.0/24 [1/20] via 4.4.4.4, eth2
C 4.4.4.0/24 [1] is directly connected, eth2, Area 0.0.0.0
E2 6.6.6.6/32 [1/20] via 4.4.4.4, eth2
E2 8.8.8.8/32 [1/20] via 4.4.4.4, eth2
E2 192.168.20.0/24 [1/20] via 4.4.4.4, eth2