L3 · addressing · reviewed

VRF

Virtual routing and forwarding instances

Gives one router several independent routing tables, so overlapping address space can coexist and traffic cannot cross between tenants by accident.

Presenter modeEmbed this figure

The VPN-IPv4 Address FamilyRFC 4364 · PROPOSED STANDARD · February 2006The Route Target AttributeRFC 4364 · PROPOSED STANDARD · February 2006Multiprotocol Reachable NLRI - MP_REACH_NLRI (Type Code 14):RFC 4760 · DRAFT STANDARD · January 2007Private Address SpaceRFC 1918 · BEST CURRENT PRACTICE · February 1996

Why it exists

A router has one routing table, and a routing table can hold one route per prefix. Two tenants both using 10.0.0.0/8 cannot both be in it, and since RFC 1918 space is what everyone uses, that collision arrives with every acquisition and every partner connection. Private Address SpaceRFC 1918 · BEST CURRENT PRACTICE · February 1996

A VRF is a second routing and forwarding table on the same device. Overlapping prefixes coexist because they are never compared, and traffic cannot cross between tenants because there is no route that could carry it. The VPN-IPv4 Address FamilyRFC 4364 · PROPOSED STANDARD · February 2006

It is the same mechanism MPLS L3VPN uses at scale. VRF-lite is a VRF without the MPLS transport — the separation is local to the device and carried between devices by a tag, a subinterface or a tunnel instead.

One router, two routing tables that cannot see each other

Two tenants both use 10.0.0.0/8. Without VRFs one of them has to renumber; with them, neither does.

Two tenants arrive on one router and both use 10.0.0.0/8. In a single routing table the second prefix would simply replace the first, or be rejected. Tenant A · 10.0.0.0/8: Prefix 10.0.0.0/8. Router. Tenant B · 10.0.0.0/8: Prefix 10.0.0.0/8. Internet.

Tenant A · 10.0.0.0/8Prefix: 10.0.0.0/8RouterOne table cannot hold bothTenant B · 10.0.0.0/8Prefix: 10.0.0.0/8InternetGi1 · vrf AGi2 · vrf BGi0 · global
  • Link
  • Blocking
  • Packet in flight
  • Discarded
  • Emphasis
Select a device to read its state. Arrow keys walk the topology.
Text equivalent of this diagram
Devices and links at this step
ElementKindState
Tenant A · 10.0.0.0/8zonePrefix: 10.0.0.0/8
Routerrouter
Tenant B · 10.0.0.0/8zonePrefix: 10.0.0.0/8
Internetcloud
Tenant A · 10.0.0.0/8Routerlinkup · Gi1 · vrf A
Tenant B · 10.0.0.0/8Routerlinkup · Gi2 · vrf B
RouterInternetlinkup · Gi0 · global
1 / 4

Two tenants arrive on one router and both use 10.0.0.0/8. In a single routing table the second prefix would simply replace the first, or be rejected.

This is not a corner case. RFC 1918 space is what everyone uses, 10.0.0.0/8 in particular, so every acquisition and every partner connection produces the collision.

What changed

  • Tenant A · 10.0.0.0/8: Prefix → 10.0.0.0/8
  • Tenant B · 10.0.0.0/8: Prefix → 10.0.0.0/8
  • Emphasis: One table cannot hold both

How it works

Interfaces are bound to a VRF, and the interface a packet arrives on selects the table used to forward it. Nothing in the packet says which VRF it belongs to; the binding is the whole mechanism.

Where tables need to share something, route targets do it selectively. A VRF exports its routes with a target and imports the targets it wants, and because import and export are separate lists the relationship can be asymmetric — which is how shared services and hub-and-spoke are both expressed. The Route Target AttributeRFC 4364 · PROPOSED STANDARD · February 2006

Route targets control which routes are imported. They do not control which packets may be forwarded — a VRF that has imported both tenants can route between them, and stopping that needs a filter where the forwarding happens.

On the wire

Constructed examples, encoded from the field table below them — not captured traffic.

AFI IPv6, SAFI unicast, 16-octet next hop, one /32 prefix. The IPv4 NLRI field of UPDATE is empty when reachability lives here.

BGP path attribute
Optional non-transitive. Type code 14. RFC 4760

Configure it

Two tenants with the same address space, and a shared-services VRF both can reach.

Cisco IOS-XE 17.12 · Catalyst 8500, ISR 4451, Catalyst 9300draft

  1. vrf definition CUSTOMER-A
     rd 65000:100
     address-family ipv4
      route-target export 65000:100
      route-target import 65000:100
      route-target import 65000:999

    The route distinguisher makes this tenant’s prefixes unique inside BGP. The route targets decide what is imported — importing 65000:999 is what reaches the shared services, and there is deliberately no import of the other tenant.

    Common mistake: Believing the RD controls import. It does not — it only disambiguates overlapping prefixes. Import is entirely the route target.

    RFC 4364 §4.3.1

  2. vrf definition CUSTOMER-B
     rd 65000:200
     address-family ipv4
      route-target export 65000:200
      route-target import 65000:200
      route-target import 65000:999

    The mirror image. B imports the shared target and nothing of A’s, so both tenants reach the servers and neither reaches the other.

  3. interface GigabitEthernet1
     vrf forwarding CUSTOMER-A
     ip address 10.0.0.1 255.255.255.0

    The order is the point. `vrf forwarding` removes any address already on the interface, so the address line must come after it.

    Common mistake: Configuring the address first. The VRF assignment silently removes it and the interface stops working with a configuration that reads as correct.

  4. vrf definition SHARED
     rd 65000:999
     address-family ipv4
      route-target export 65000:999
      route-target import 65000:100
      route-target import 65000:200

    SHARED imports both tenants so it can reply to both. That also means it holds routes between them, which is why the filter below is not optional.

    RFC 4364 §4.3.1

  5. ip access-list extended SHARED-NO-TRANSIT
     permit ip 10.0.0.0 0.255.255.255 host 192.0.2.53
     deny ip 10.0.0.0 0.255.255.255 10.0.0.0 0.255.255.255
     permit ip any any
    interface GigabitEthernet3
     ip access-group SHARED-NO-TRANSIT in

    Stops the shared VRF being a path between tenants. Route targets decided what it learned; only a filter decides what it will carry.

  6. router ospf 10 vrf CUSTOMER-A
     network 10.0.0.0 0.0.0.255 area 0

    A routing protocol has to be configured under the VRF. Moving an interface into a VRF does not bring a globally configured protocol with it, and the adjacency simply never forms.

Verify

show vrf
Each VRF, its RD, and the interfaces bound to it.
show ip route vrf CUSTOMER-A
Only this tenant’s routes plus the shared prefix.
ping vrf CUSTOMER-A 192.0.2.53
Reachability from inside the table, not from global.
show ip vrf interfaces
Any interface that was meant to be in a VRF and is not.

Caveats

  • `vrf forwarding` removes the interface address. Always assign the VRF first and the address second.
  • Every diagnostic needs the VRF named; without it the command queries the global table and reports a failure that is not real.
  • Route targets control import, not forwarding. A VRF that imports two tenants can route between them.

When it breaks

Symptom first, because that is what you have when it happens.

  1. An interface is put into a VRF and stops working, and its running configuration has no IP address.

    Narrow it down

    1. Compare the configuration before and after the VRF assignment.
    2. Check whether the address line is simply absent rather than wrong.
    3. Look for a warning in the session scrollback, which some platforms emit and some do not.

    Cause

    Assigning a VRF removes the address, because the address belonged to a table the interface has left and may collide in the one it is joining.

    Fix

    Re-apply the address after the assignment. In a change script, always order it that way.

  2. A destination is unreachable from the router and reachable from a host on the same segment.

    Narrow it down

    1. Check whether the command named the VRF.
    2. Run the same command with the VRF specified and compare.
    3. Confirm which table the source address belongs to.

    Cause

    The command used the global table. `ping` without a VRF sources from global, finds no route, and reports unreachable — which reads as a network fault rather than a missing keyword.

    Fix

    Name the VRF in every diagnostic. It is the single most common VRF support ticket and it is never a network problem.

  3. Two tenants that must not reach each other can, and the route targets appear correct.

    Narrow it down

    1. Check what the shared-services VRF has imported.
    2. Trace whether traffic between tenants transits it.
    3. Look for a filter on the shared VRF — its absence is usually the answer.

    Cause

    The shared VRF imported both tenants, so it holds routes to both and will forward between them. Route targets decided what it learned, not what it may carry.

    Fix

    Filter at the shared VRF, or use a design where the servers never initiate and the tenants never transit.

    The Route Target AttributeRFC 4364 · PROPOSED STANDARD · February 2006
  4. A routing protocol is configured and forms no adjacency on interfaces that are in a VRF.

    Narrow it down

    1. Check whether the protocol instance was configured under the VRF or globally.
    2. Confirm the interface is in the VRF the protocol instance names.
    3. Look at whether the platform requires a separate process per VRF.

    Cause

    The protocol is running in the global table and the interfaces are not. Some platforms need an address family per VRF; others need a separate process entirely.

    Fix

    Configure the protocol under the VRF. The interface binding does not move a globally configured protocol along with it.

  5. Two VRFs both advertise 10.0.0.0/8 into BGP and one prefix vanishes or overwrites the other at a PE.

    Narrow it down

    1. Compare the route distinguishers configured on each VRF.
    2. Confirm the routes appear as distinct VPN-IPv4 NLRIs, not as plain IPv4.
    3. Check whether import is filtering by route target rather than by RD.

    Cause

    Identical RDs on overlapping prefixes collapse them into one BGP path. The RD’s job is uniqueness inside BGP, not import selection — that is the route target.

    Fix

    Give every VRF a unique RD. Keep import policy on route targets; never treat the RD as a security boundary.

    The VPN-IPv4 Address FamilyRFC 4364 · PROPOSED STANDARD · February 2006

Design notes

Assign the VRF before the address, always. Moving an interface into a VRF removes its address on most platforms, and re-applying afterwards is one command against a change window spent looking for a routing fault that is not there.

Name VRFs for the tenant, not the technology. `CUSTOMER-A` survives a migration from VRF-lite to MPLS; `VRF1` tells nobody anything and is what every device ends up with.

A shared-services VRF is a transit risk by construction. It holds routes to everything that imports from it, and the import policy that made that convenient will not stop it forwarding between them. Put an access list on it or make the servers non-initiating.

Budget for the operational cost. Every diagnostic command needs the VRF named, monitoring has to be VRF-aware, and a management session sourced from the wrong table fails in a way that looks like the network. This is the reason not to use VRFs where a subnet would do.

Misconceptions

A VRF is a VLAN for layer 3.
A VLAN separates a broadcast domain; a VRF separates a routing table. They solve different problems at different layers and are routinely used together — a VLAN per tenant segment, a VRF holding the routes for all of that tenant’s segments.
VRFs require MPLS.
MPLS L3VPN uses VRFs and VRFs do not require it. VRF-lite carries the separation between devices with a tagged subinterface or a tunnel instead, which is how most enterprise deployments work.
Route targets enforce isolation.
They control which routes a table imports. Once a VRF holds routes to two tenants it can forward between them, and the import policy has nothing to say about that. Isolation between tenants sharing a VRF is a filtering problem. The Route Target AttributeRFC 4364 · PROPOSED STANDARD · February 2006
The route distinguisher decides which VRF a route lands in.
It makes overlapping prefixes unique inside BGP so two tenants can both advertise 10.0.0.0/8. Import is decided entirely by the route target. This is the single most confused pair in the technology. The VPN-IPv4 Address FamilyRFC 4364 · PROPOSED STANDARD · February 2006

More walkthroughs

Letting exactly one thing crossdesign-choice

Tenants need shared services. Route targets let specific prefixes cross between tables without the tables merging.

Both tenants need the same DNS and NTP servers. Merging the VRFs would give them each other as well, which is exactly what the separation was for. VRF A. Router. VRF B. VRF SHARED · DNS, NTP: Holds 192.0.2.0/24.

VRF ARouterVRF BVRF SHARED · DNS, NTPHolds: 192.0.2.0/24
  • Link
  • Blocking
  • Packet in flight
  • Discarded
  • Emphasis
Select a device to read its state. Arrow keys walk the topology.
Text equivalent of this diagram
Devices and links at this step
ElementKindState
VRF Azone
Routerrouter
VRF Bzone
VRF SHARED · DNS, NTPzoneHolds: 192.0.2.0/24
VRF ARouterlinkup
VRF BRouterlinkup
RouterVRF SHARED · DNS, NTPlinkup
1 / 5

Both tenants need the same DNS and NTP servers. Merging the VRFs would give them each other as well, which is exactly what the separation was for.

What changed

  • VRF SHARED · DNS, NTP: Holds → 192.0.2.0/24
  • Emphasis on VRF SHARED · DNS, NTP

The VRF that swallowed the addressesfailure

Assigning an interface to a VRF removes its IP address on most platforms. The configuration looks right and nothing works.

Gi1 has an address and the host is reachable. Everything is in the global table. Router: Gi1 10.1.1.1/24. Host. Upstream.

RouterGi1: 10.1.1.1/24HostUpstreamGi1Gi0
  • Link
  • Blocking
  • Packet in flight
  • Discarded
  • Emphasis
Select a device to read its state. Arrow keys walk the topology.
Text equivalent of this diagram
Devices and links at this step
ElementKindState
RouterrouterGi1: 10.1.1.1/24
Hosthost
Upstreamcloud
RouterHostlinkup · Gi1
RouterUpstreamlinkup · Gi0
1 / 4

Gi1 has an address and the host is reachable. Everything is in the global table.

What changed

  • Router: Gi1 → 10.1.1.1/24
  • Emphasis on Router ↔ Host

Terms

VRF
A separate routing and forwarding table on one device. Interfaces are bound to it, and the interface a packet arrives on selects the table — nothing in the packet does.
Route leaking
Importing specific routes from one VRF into another without merging the tables. Import and export lists are separate, so the relationship can be one-way — which is how shared services and hub-and-spoke are both built.
VRF-lite
VRFs without MPLS. The table separation is identical; what differs is that separation is carried between devices by a tagged subinterface or a tunnel rather than by a label.

Check yourself

  • What selects which routing table a router uses for an arriving packet?
  • Two tenants both use 10.0.0.0/8 on one router. How do VRFs make that work?
  • Two tenant VRFs both import a shared-services VRF. Can the tenants reach each other?
  • You assign an interface to a VRF and it stops working. What happened?
  • What distinguishes VRF-lite from MPLS L3VPN?
  • What does the route distinguisher decide?
  • A host on a VRF segment can reach a destination, but ping from the router reports unreachable. What usually happened?
  • OSPF is configured globally and the interfaces are in a VRF. Why is there no adjacency?