VRF-aware routing

OSPF, EIGRP, BGP, IS-IS and static routes all work per VRF, but each names the VRF in a different place. OSPF takes it on the process line, BGP and EIGRP on an address family, a static route on the command itself. They all fail the same silent way: the configuration is accepted, and the routes land in a table nobody is reading, or in none.

In Daveth Pro (Network)7 min video · lab: Routing basics, deep

By , founder of Daveth · Updated

Opening frame of the video walkthrough of VRF-aware routing

Watch this lesson

7 min · Video walkthrough

In Daveth Pro (Network)

The full 7 min walkthrough is in Daveth Pro (Network). See what the plan opens

Upcoming practical lab

Lab C3: Routing basics, deep

What the lab covers

What this page answers

How do you configure OSPF in a VRF?

On the process line: router ospf process vrf name. The process number is only locally meaningful; the name after vrf binds it to the tenant, and a mistyped name fails silently. Read it in “On the process line: OSPF”

How do you configure BGP in a VRF?

Under router bgp, open address-family ipv4 vrf name, define the neighbour inside the family, and activate it there: a neighbour that is not activated advertises nothing in that family. Read it in “On an address family: BGP and EIGRP”

How do you add a static route to a VRF?

With the VRF on the command itself, ip route vrf name prefix mask next-hop, for example ip route vrf TENANT-B 0.0.0.0 0.0.0.0 172.16.20.1. Read it in “On the command: static routes”

A table with nothing in it

CE-1 has two VRFs, TENANT-A and TENANT-B, and both tables hold only their connected links. Building a VRF was the previous lesson. What puts routes in?

A device can run more than one routing protocol inside a VRF, and most of the usual ones are VRF-aware. OSPF, EIGRP, BGP, IS-IS and static routes all work per-VRF.

And the process is the same each time, which is the half-truth this page is about. The mechanism is the same: the protocol learns routes and puts them in a table. Where you type the VRF name is not the same. It moves from one place to another depending on the protocol, and that is the whole difficulty.

On the process line: OSPF

OSPF takes the VRF on the process line itself: router ospf <process> vrf <name>. One process, one VRF, and the process number is only locally meaningful: what binds it to a tenant is the name after vrf.

Watch the name, not the number. A VRF called v11 and one called vl1 are different tables, and on a terminal they are the same three shapes. Every routing protocol on this page fails the same silent way: the configuration is accepted, the protocol runs, and its routes land in a table nobody is looking at, or in no table at all, because the name never matched a VRF that exists.

Configuration: OSPF in TENANT-A, toward SW-A, on this network, with this scenario's names and numbers.

CE-1# configure terminal
CE-1(config)# router ospf 1 vrf TENANT-A
CE-1(config-router)# network 172.16.1.0 0.0.0.3 area 0
CE-1(config-router)# end

Which table did the routes OSPF learned from SW-A land in?

Computed from the state: TENANT-A's table after it. No command prints it.

prefix              from                              in the table
172.16.1.0/30       connected                         yes
172.16.10.0/30      connected                         yes
10.20.0.0/16        OSPF 1                            yes

Look at the from column. Two connected links, and one prefix learned from SW-A, in TENANT-A because the process line named it.

On an address family: BGP and EIGRP

BGP does not take the VRF on router bgp. Where does it go?

BGP takes it on an address family. router bgp <as> stays tenant-agnostic, and underneath it address-family ipv4 vrf <name> opens the part that belongs to one tenant. Neighbours for that tenant are defined inside the family.

And defining a neighbour is not the same as using it. Inside the family the neighbour has to be activated before anything is advertised to it in that family.

Notice where the neighbour is defined: inside the family, not under router bgp itself. Where would you look first if a second tenant's neighbour showed up in the wrong table?

Configuration: BGP to PE-1 in TENANT-A, on this network, with this scenario's names and numbers.

CE-1# configure terminal
CE-1(config)# router bgp 65010
CE-1(config-router)# address-family ipv4 vrf TENANT-A
CE-1(config-router-af)# neighbor 172.16.10.1 remote-as 65100
CE-1(config-router-af)# neighbor 172.16.10.1 activate
CE-1(config-router-af)# end

Is the neighbour activated in TENANT-A's family, and does it advertise IPv4?

Computed from the state: the neighbour. No command prints it.

neighbour             172.16.10.1 remote-as 65100
activated             yes
advertises IPv4       yes

By this course's reading, a neighbour without activate advertises nothing in the IPv4 family. That is an inference from what activation is for, not something any output on this page shows you: no reading here prints the difference, so treat it as a reason to check rather than a fact you have seen.

EIGRP also takes the VRF on an address family, and adds an autonomous system number. Is the number required?

Type it. Whether it is strictly required or merely advised is stated inconsistently in different places, and it can go either on the address-family line itself or on a command of its own beneath it. None of that ambiguity costs you anything if you put it on the address-family line every time, and it costs you a confusing failure if you leave it off on the release where it turns out to matter.

One thing it does not mean. The number here is not a second, different AS from the one on router eigrp. It is the same autonomous system, named again in the place that binds it to this tenant.

Configuration: classic EIGRP in TENANT-B, on this network, with this scenario's names and numbers.

CE-1# configure terminal
CE-1(config)# router eigrp 10
CE-1(config-router)# address-family ipv4 vrf TENANT-B autonomous-system 30
CE-1(config-router-af)# end

Computed from the state: the number, read against both pages. No command prints it.

process               EIGRP 10, AS 30 in TENANT-B
read as required      required, and configured
read as advised       recommended, and configured

And what has TENANT-B's table learned?

Computed from the state: TENANT-B's table. No command prints it.

prefix              from                              in the table
172.16.2.0/30       connected                         yes
172.16.20.0/30      connected                         yes
10.30.0.0/16        EIGRP 10, AS 30                   yes

Read the table against TENANT-A's. Different learned prefixes and different sources on one device, each held in its own VRF. Would a route in one ever appear in the other without something moving it? That is 1.2.f.

On the command: static routes

A static route takes the VRF name on the command itself, as ip route vrf. Does a default toward PE-1 land in TENANT-B's table?

Configuration: a default route in TENANT-B, toward PE-1, on this network, with this scenario's names and numbers.

CE-1# configure terminal
CE-1(config)# ip route vrf TENANT-B 0.0.0.0 0.0.0.0 172.16.20.1
CE-1(config)# end

Computed from the state: TENANT-B's table. No command prints it.

prefix              from                              in the table
172.16.2.0/30       connected                         yes
172.16.20.0/30      connected                         yes
10.30.0.0/16        EIGRP 10, AS 30                   yes
0.0.0.0/0           static via 172.16.20.1            yes

The next hop is on TENANT-B's own link to PE-1, so the route goes into the table. What about a static whose next hop is reached through a route the VRF learned?

Then it depends on where the next hop is allowed to be resolved. By default a static route's next hop is looked up in the global table, not in the VRF, so a static inside a VRF whose next hop is only reachable through a route that same VRF learned never reaches the table. There is a knob that changes it, and it takes the VRF name.

Now TENANT-A, which OSPF filled with 10.20.0.0/16. A static to 10.20.5.0/24 via 10.20.9.1 has both its next hop and its destination inside that learned route.

Configuration: the static in TENANT-A, on this network, with this scenario's names and numbers.

CE-1# configure terminal
CE-1(config)# ip route vrf TENANT-A 10.20.5.0 255.255.255.0 10.20.9.1
CE-1(config)# end

Predict the result row before you read it. In TENANT-A's table, or not?

Computed from the state: before the knob. No command prints it.

static          10.20.5.0/24 via 10.20.9.1
knob in VRF     no
result          not in the table: recursive, and the default leaves it out

By this course's reading of the feature sentence and its example, that is the recursive case the default leaves out of the table. The page names no output that says so.

Configuration: the knob, for TENANT-A only, on this network, with this scenario's names and numbers.

CE-1# configure terminal
CE-1(config)# ip route static install-routes-recurse-via-nexthop vrf TENANT-A
CE-1(config)# end

Is it in the table now?

Computed from the state: after it. No command prints it.

static          10.20.5.0/24 via 10.20.9.1
knob in VRF     yes
result          in the table

Notice the vrf keyword on the knob. It is what leaves TENANT-B on the default. Does TENANT-B need the knob? Not for a static whose next hop is connected.

The PE-to-CE command

OSPF has one more command here, capability vrf-lite, and when to issue it is genuinely ambiguous. CE-1 runs OSPF 1 in TENANT-A toward SW-A, and BGP to PE-1. Does it need the command?

Two different conditions are given for it, and they are not the same condition. One is about the link: issue it where OSPF is the protocol between the provider edge and the customer edge. The other is about the device: issue it on a router that is not a provider edge, meaning one that is not running BGP.

On CE-1 as it stands, neither applies. OSPF faces the customer switches, not the provider; and CE-1 does run BGP. Keep both conditions in view, because the next step separates them.

Computed from the state: OSPF 1 in TENANT-A. No command prints it.

process               OSPF 1 in TENANT-A, toward the tenant switch
by the link           not the case it names
issued                no

What does the command actually do? It turns off the extra checks a provider edge makes on OSPF routes: the ones that exist because a provider edge is meant to be part of a VPN backbone. On a customer edge those checks are looking for something that is not there, and they discard routes you wanted.

Now TENANT-B's provider asks for OSPF on the PE link. CE-1 gets OSPF 2 in TENANT-B, facing PE-1, and the two conditions come apart.

Configuration: OSPF 2 in TENANT-B, toward PE-1, on this network, with this scenario's names and numbers.

CE-1# configure terminal
CE-1(config)# router ospf 2 vrf TENANT-B
CE-1(config-router)# network 172.16.20.0 0.0.0.3 area 0
CE-1(config-router)# end

What does each condition say about OSPF 2?

Computed from the state: OSPF 2 in TENANT-B, before the command. No command prints it.

process               OSPF 2 in TENANT-B, toward PE-1
by the link           issue it
by the device         running BGP, which is not the case it names
issued                no

Look at the two highlighted rows. By the link, issue it. By the device, do not.

By this course's reading, the two conditions disagree on CE-1, and the link is the one that decides. OSPF 2 is the protocol between provider edge and customer edge, so the extra checks it turns off are exactly the ones in play. That CE-1 also runs BGP in another tenant is a fact about a different VRF, and a per-process command is not decided by what a different process is doing. The command goes on, and this page does not claim the device-level condition is met.

The blast radius of this change is TENANT-B. TENANT-A's BGP session and table are a different VRF, and nothing in this step touches them.

Configuration: the command under OSPF 2, on this network, with this scenario's names and numbers.