Sub topic 8
VRFs, Route Distinguishers, Route Targets, and MP-BGP
This chapter assumes you can read basic Cisco IOS configuration, know what iBGP and eBGP sessions are, and have read the previous chapter on MPLS Layer 3 VPNs. That chapter explained that a provider carries many customers over one MPLS core. This chapter covers the four mechanisms that keep those customers separate and let each customer's sites reach each other.
The problem: overlapping customers on shared routers
Two customers can both use 10.1.0.0/16 internally. A single provider edge (PE) router may connect both of them. If the PE had one routing table, the two routes would collide. The provider also cannot ask customers to renumber.
Four mechanisms solve this:
- A VRF gives each customer a separate routing table on the PE.
- A route distinguisher (RD) makes overlapping prefixes unique when they are carried in BGP.
- A route target (RT) decides which VRFs install which routes.
- MP-BGP carries the routes, RTs, and VPN labels between PEs.
VRFs: one routing table per customer
A VRF (virtual routing and forwarding instance) is a separate routing table and forwarding table inside one router. You assign interfaces to a VRF. A packet arriving on that interface is looked up only in that VRF. The router's normal table, the global table, stays separate and holds the provider's own routes, such as the core IGP.
A VRF is local to one router. Nothing in the VRF definition tells other routers about it. The name CUST_A on one PE need not match the name on another PE, because only RDs and RTs travel in BGP.
Route distinguishers: making prefixes unique
An RD is a 64-bit value. A PE prepends it to a 32-bit IPv4 prefix to create a 96-bit VPNv4 prefix. With RD 65000:100, the customer route 10.1.0.0/16 becomes 65000:100:10.1.0.0/16. A second customer using RD 65000:200 and the same prefix produces a different VPNv4 prefix, so BGP treats the two as distinct routes.
The RD does not say which customer or VPN a route belongs to. It only provides uniqueness. Many designs use one RD per VRF per PE, so that a route learned through two PEs stays visible as two separate paths. That matters for load sharing and fast convergence.
Route targets: deciding who imports what
An RT is a BGP extended community attached to a VPNv4 route. It controls membership:
- Export RT: attached to routes leaving a VRF for MP-BGP.
- Import RT: a VRF installs a received VPNv4 route only if the route carries at least one RT the VRF imports.
| Item | Size and form | Job | Where it is used |
|---|---|---|---|
| RD | 64 bits, such as `65000:100` | Makes overlapping prefixes unique | Part of the VPNv4 prefix |
| RT | Extended community, such as `65000:100` | Selects which VRFs receive a route | Attached to the route, matched on import |
Because import and export are separate, you can build topologies without changing the core:
- Full mesh: every site imports and exports the same RT. This is the usual any-to-any VPN.
- Hub and spoke: spokes export a spoke RT and import only the hub RT. The hub imports the spoke RT and exports the hub RT. Spokes can then reach only the hub.
- Extranet or shared services: a shared-services VRF exports one RT that many customer VRFs import.
MP-BGP between the PEs
PEs exchange customer routes over iBGP sessions with the VPNv4 address family. This is why the protocol is called Multiprotocol BGP (MP-BGP). Standard IPv4 BGP cannot carry a 96-bit prefix or the RT.
The core P routers do not run BGP for customer routes and have no VRFs. They only forward labeled packets. This is why the provider core scales: customer routes live only at the edge.
The VPNv4 update also carries a VPN label, which the advertising PE chooses. The next hop is the advertising PE's loopback address. The data path therefore uses two labels:
- The transport label (top of the stack) is learned through LDP and gets the packet across the core to the egress PE's loopback.
- The VPN label (bottom of the stack) is learned through MP-BGP and tells the egress PE which VRF or interface the packet belongs to.
Because of penultimate hop popping, the last P router usually removes the transport label. The egress PE then receives only the VPN label.
Reading the PE configuration
The next configuration is for PE1. The core-facing MPLS configuration from the previous chapter is assumed.
vrf definition CUST_A
rd 65000:100
address-family ipv4
route-target export 65000:100
route-target import 65000:100
exit-address-family
!
interface GigabitEthernet0/2
vrf forwarding CUST_A
ip address 192.168.10.1 255.255.255.252
no shutdown
!
router bgp 65000
neighbor 10.255.255.2 remote-as 65000
neighbor 10.255.255.2 update-source Loopback0
address-family vpnv4
neighbor 10.255.255.2 activate
neighbor 10.255.255.2 send-community extended
exit-address-family
address-family ipv4 vrf CUST_A
neighbor 192.168.10.2 remote-as 65010
neighbor 192.168.10.2 activate
exit-address-familyReading it in order:
rdand the tworoute-targetlines define the VRF's identity, its export policy, and its import policy.vrf forwarding CUST_Aplaces the customer-facing interface in the VRF. Enter it beforeip address. IOS removes any address already on the interface when you apply a VRF.- The global
neighbor ... remote-as 65000line is an iBGP session to PE2's loopback 10.255.255.2. Usingupdate-source Loopback0keeps the session up when a physical link fails. - Under
address-family vpnv4,activateenables VPNv4 exchange.send-community extendedsends the RT with each route. - Under
address-family ipv4 vrf CUST_A, the PE runs eBGP with the CE at 192.168.10.2, which is in AS 65010. The PE redistributes these routes into VPNv4 automatically.
The PE-CE protocol is a separate choice. Static routes, OSPF, EIGRP, and eBGP all work, and the provider core is unaffected by which one a customer picks.
Verifying and troubleshooting
Always include the VRF name in per-customer commands. A plain show ip route shows only the global table.
show ip route vrf CUST_A
show bgp vpnv4 unicast all
show bgp vpnv4 unicast rd 65000:100 10.1.0.0/16
show mpls forwarding-table
ping vrf CUST_A 10.2.0.1Common errors:
- Missing
send-community extended. The VPNv4 session comes up, but routes arrive without RTs, so no VRF imports them. This is the most frequent cause of "BGP is up but the site is unreachable". - Mismatched RTs. PE1 exports
65000:100and PE2 imports65000:101. The route is in the VPNv4 table on PE2 but never reaches the VRF. - No RD. An IPv4 address family under a VRF without an
rdis not usable for VPN routing. - Loopback not reachable in the core. If PE2's loopback is not in the IGP and LDP, the BGP next hop has no transport label, and traffic is dropped even though the routes look correct.
mpls ipmissing on a core link. The label stack breaks at that hop.- Same AS at every customer site. The customer's AS 65010 appears in the AS path of routes from site 1. The CE at site 2 sees its own AS and rejects them as a loop. Fix this on the PE with
neighbor ... as-override, or on the CE withallowas-in. - Pinging from the global table.
ping 10.2.0.1searches the global table. Useping vrf CUST_A 10.2.0.1.
Why it matters for WAN choice
This model explains MPLS VPN behavior that later chapters compare against other technologies. The provider, not the customer, controls the routing policy that connects sites. Any-to-any connectivity needs no tunnel mesh. Customer prefixes sit only on PEs. The cost is dependence on the provider for every change, such as a new RT or a new site.
Exercise
PE1 has VRF CUST_A with RD 65000:100, export RT 65000:100, and import RT 65000:100. PE2 has the same VRF with RD 65000:200, export RT 65000:100, and import RT 65000:100. Will the two sites exchange routes, and why does the different RD not matter? Then name the one command line whose absence would stop PE2 from importing PE1's routes even though the VPNv4 session is established.
Show answer
Yes, the sites exchange routes. Import and export RTs match on both PEs, so each VRF imports the other's routes. The RD only makes the VPNv4 prefixes unique and plays no part in import decisions, so different RDs are harmless and can even help with path diversity. The missing line would be neighbor 10.255.255.x send-community extended under address-family vpnv4. Without it, the RT is not sent, so the receiving PE has no RT to match against its import list.
Exercise
A packet crosses the provider core from CE1 to CE2. How many labels does it carry between the first P router and the last P router, which one is at the top of the stack, and what does each label identify?
Show answer
It carries two labels. The top label is the transport label learned from LDP, which identifies the LSP to the egress PE's loopback. The bottom label is the VPN label learned from MP-BGP, which identifies the VRF or customer interface at the egress PE. The last P router normally pops the transport label through penultimate hop popping, so the egress PE receives only the VPN label.