Virtual routing and forwarding

Also known as: VRF

On this page 7

Virtual routing and forwarding (VRF) is a technology that allows a single router or layer 3 switch to maintain multiple independent routing tables at the same time, each with its own interfaces, routes and forwarding decisions. In routing, a VRF behaves like a separate virtual router inside one physical device, so traffic in one VRF cannot reach another unless an engineer explicitly allows it.

VRFs are the foundation of MPLS layer 3 VPNs, multi-tenant data centers and the separation of management traffic from production traffic. Because each table is isolated, different VRFs can even use overlapping IP address ranges without conflict.

How VRF separates routing tables

A VRF instance consists of a routing table, a forwarding table (FIB) and a set of assigned interfaces. When a packet arrives on an interface, the device looks up the destination only in the table of the VRF that owns that interface, applying longest prefix match within that table alone.

Every routed interface or subinterface belongs to exactly one VRF. Interfaces that are not assigned explicitly stay in the global or default VRF. Routing protocols such as OSPF, BGP or static routes are configured per VRF, so each instance learns and advertises only its own prefixes.

The following table shows the main components of a VRF and their roles in the forwarding process.

ComponentRoleScope
Routing table (RIB)Holds routes learned for this VRFPer VRF
Forwarding table (FIB)Hardware lookup used to forward packetsPer VRF
Member interfacesBind incoming traffic to the VRFEach interface in one VRF
Route distinguisherMakes overlapping prefixes unique in MP-BGPPer VRF, used with MPLS VPNs
Route targetsControl which VRFs import or export routesPer VRF, import and export lists
Building blocks of a VRF instance

VRF-lite and MPLS VPN variants

VRFs appear in two main forms. VRF-lite uses VRFs on individual devices without MPLS, extending separation hop by hop with VLAN subinterfaces or tunnels. MPLS layer 3 VPN, described in RFC 4364, combines VRFs on provider edge routers with MP-BGP and MPLS labels to carry many customer networks across a shared backbone.

ModelTransport between devicesTypical useScaling
VRF-litePer-VRF VLANs, subinterfaces or GRECampus and branch segmentationLimited, configuration grows per hop
MPLS L3VPNMPLS labels with MP-BGPService provider and large enterprise WANThousands of VRFs
EVPN with VXLANVXLAN tunnels with BGP EVPNMulti-tenant data center fabricsHigh, automated
Management VRFDedicated out-of-band portIsolating device managementSingle VRF per device
Comparison of VRF deployment models

In MPLS VPNs, the route distinguisher, a 64-bit value, is prepended to each IPv4 prefix to form a unique VPNv4 route. Route targets, which are BGP extended communities, decide which VRFs receive each route, enabling hub-and-spoke, full-mesh or extranet designs.

VRF provides separation at layer 3, which differs from separation at layer 2 or by policy. Engineers often combine several methods, so it helps to see what each one actually isolates.

TechniqueLayerWhat it isolatesLimitation
VRFLayer 3Routing tables and forwarding pathsNo filtering inside a VRF
VLANLayer 2Broadcast domainsRouting between VLANs merges them unless VRFs are used
Access control listsLayer 3 and 4Specific flows by ruleShared routing table, complex to maintain
Policy-based routingLayer 3Path choice for matched trafficDoes not provide address separation
Separate physical routersAllEverythingHigh cost and space
VRF and other ways to segment networks

The key difference is that VRFs isolate the control plane and forwarding decisions, whereas ACLs only filter traffic within one shared table. A VRF is also not the same as a full virtual router instance that duplicates the entire operating system; VRFs share the device CPU, memory and management plane.

Route leaking and shared services

Strict isolation is rarely absolute in practice, because tenants often need shared services such as DNS, internet access or backup servers. Controlled exchange of routes between VRFs is called route leaking.

Route leaking can be done with static routes that point into another VRF, with route target import and export in BGP, or by sending traffic through a firewall that connects both VRFs. The firewall approach is usually preferred for security, since it inspects every flow instead of simply merging reachability.

Leaking requires that the shared addresses do not overlap with any tenant range, and that NAT is used when they do. Uncontrolled leaking is a frequent cause of unintended reachability between segments that were meant to be separate.

Design guidance and common pitfalls

VRFs are powerful but add operational complexity, since every command that touches routing must name the correct instance. The table pairs typical situations with sensible choices.

SituationRecommended approachReason
Separating guest and corporate trafficVRF-lite with a firewall at the edgeSimple, strong separation
Many customers on one WAN backboneMPLS L3VPNScales to many VRFs
Protecting device managementDedicated management VRFKeeps admin access off data paths
Tenants with overlapping addressesOne VRF per tenant plus NAT for shared servicesAvoids address conflicts
When to use VRF and how

Common mistakes include running ping or traceroute in the wrong VRF, forgetting to bind a routing protocol to the VRF, and assuming that VRF separation equals security filtering. Hardware also imposes limits on VRF count and FIB size, which must be checked before scaling a design. Clear naming conventions and documented route targets make troubleshooting far easier when dozens of VRFs share the same routers.

The short version

Virtual routing and forwarding lets one router act like several separate routers. Think of an apartment building with one entrance but separate, locked apartments. Each apartment has its own address book of routes, and residents cannot walk into another apartment.

This means two companies can share the same equipment and even use the same internal addresses without ever seeing each other’s traffic, unless someone deliberately opens a door between them.

Where it makes a difference

A university campus network carries traffic for students, staff, a research cluster and building management systems on the same core switches. The network team creates four VRFs, one for each group, and assigns the relevant VLAN interfaces to them. The building management VRF has no default route to the internet at all.

All VRFs reach the internet and shared DNS only through a central firewall with one interface per VRF, where policies are enforced. When a student laptop is infected with malware a year later, it scans the network but cannot discover any heating or access control devices, because their routes simply do not exist in the student routing table. The incident stays confined to one segment and is resolved within hours.