Course contents

Module 6: Advanced OSPFLesson 6.7 (7 of 8 in this module)28 of 29 in the OSPF course

OSPF in a VRF: separate processes on one router

Run one OSPF process per VRF, keep overlapping addresses apart, and verify each routing table on its own.

Advanced · 10 min read

One router, several customers

A service provider edge router, or a campus core that separates departments, can carry several independent networks. A VRF gives each one its own routing table and interfaces. Each VRF runs its own OSPF process, so neighbours, link-state databases and routes stay separate.

One router, two OSPF processes, two routing tables
One router, two OSPF processes, two routing tablesRouter R2 runs OSPF process 10 in VRF CUST-A and process 20 in VRF CUST-B. Each has its own interfaces, neighbours and routes, even when the addresses overlap.R2 (one router)VRF CUST-AVRF CUST-Brouter ospf 10 vrf CUST-AGi0/1 10.1.0.1/30 to CE-Arouter ospf 20 vrf CUST-BGi0/2 10.1.0.1/30 to CE-BOverlapping 10.1.0.1/30 is allowed because the tables are separate

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Each VRF has its own OSPF process and its own link-state database. Both customers can use 10.1.0.0/16 without clashing.

Configure a VRF and an OSPF process

Create the VRF, place the interface in it, and only then set the address: moving an interface into a VRF removes its IP address.

vrf definition CUST-A address-family ipv4 exit-address-family ! interface GigabitEthernet0/1 vrf forwarding CUST-A ip address 10.1.0.1 255.255.255.252 ! router ospf 10 vrf CUST-A router-id 10.255.10.1 network 10.1.0.0 0.0.0.3 area 0

R2, global configuration. Repeat for CUST-B with Gi0/2 and 'router ospf 20 vrf CUST-B'. Each VRF needs its own OSPF process.

Verify per VRF

show ip ospf neighbor show ip ospf 10 neighbor show ip route vrf CUST-A ospf ping vrf CUST-A 10.1.0.2

Add the process number or vrf keyword to see one VRF. A plain show or ping reads the global table.

Illustrative Cisco IOS XE output written for this lesson, not a router capture
R2#show ip route vrf CUST-A ospf
Routing Table: CUST-A
O     10.1.1.0/24 [110/2] via 10.1.0.2, 00:03:42, GigabitEthernet0/1
The routing table is named for the VRF. The same prefix in CUST-B's table is a different route.

If a neighbour does not form, compare the same things as in any OSPF link, and also check that both the interface and the process are in the right VRF. An interface in the global table cannot form an adjacency with a process that belongs to a VRF.

Check your understanding

Predict · scenario 1

You add 'vrf forwarding CUST-A' to an interface that already has an address. What happens to the address?

Predict · scenario 2

How many OSPF processes does a router need for two VRFs and the global table?

Predict · scenario 3

'show ip route ospf' on R2 shows nothing, but CUST-A has OSPF neighbours. What is likely missing?

FAQ

What is a VRF?
A virtual routing and forwarding instance: its own routing table and set of interfaces on one router. Two VRFs can use the same addresses without conflict.
What does VRF-Lite mean?
VRFs used without MPLS or MP-BGP. Each VRF has its own routing protocol instance on the router, and the VRFs are not connected to each other unless you configure that.
Why do commands need the vrf keyword?
Without it, show and ping use the global routing table. A neighbour in a VRF will not appear in the plain show ip ospf neighbor output of another process.