From point A to point B
Point A: you know that MPLS switches on labels, and you know the P, PE and CE roles. Point B: by the end of this chapter you will understand how a complete MPLS L3VPN is built: the core with OSPF and LDP, iBGP between the PEs, VRFs, the route distinguisher, the route target and the VPN label, on the same topology as the lab.
This chapter goes with the second part of Day 1. Jesús draws the solution on the whiteboard before opening the console.
- The lab topology: routers, loopbacks and label ranges
- The build steps and the BGP free core
- Peer-to-peer VPN versus overlay, and VRFs
- Route distinguisher, VPNv4 prefix and route target
- Why LDP tunnels scale better than a BGP core with GRE
The lab topology
The Day 1 lab runs in GNS3 with Cisco routers. It has a core of four routers in a line and two customers, A and B, with one site on each side. In the class, Customer A is configured end to end; Customer B stays on the whiteboard as the provider's second customer.
The Day 1 topology: four provider routers, iBGP only between the PEs, and one VRF per Customer A site. Diagram: The House of Routing.
| Router | Role | Loopback 0 | Label range |
|---|---|---|---|
| PE-1 | PE | 1.1.1.1/32 | 100–199 |
| P1 | P | 2.2.2.2/32 | 200–299 |
| P2 | P | 3.3.3.3/32 | 300–399 |
| PE-2 | PE | 4.4.4.4/32 | 400–499 |
Each router uses its own label range on purpose. That way, when you see a label in a traceroute or in the forwarding table, you will know which router assigned it. The core links are /30s: 10.10.10.0, 10.10.11.0 and 10.10.12.0.
Customer A sites run OSPF process 20. CE-A1 has loopbacks 30.30.30.30 and 31.31.31.31 and reaches PE-1 over 192.168.1.0/24. CE-A2 has 40.40.40.40 and 41.41.41.41 and reaches PE-2 over 192.168.2.0/24. The core uses OSPF process 1 in area 0: the different number helps you see what belongs to the customer and what belongs to the provider.
The customer does not see MPLS
The first idea on the whiteboard: the customer is agnostic to the MPLS core. Between the CE and the PE you can run OSPF, EIGRP, an eBGP session or static routes. The customer does not care what sits in the middle.
And there is no MPLS toward the customers. MPLS lives only inside the provider core. The PE interfaces facing the CE run neither LDP nor the core OSPF: they belong to the customer's VRF.
The build steps
- Configure the CEs: loopbacks, the interface toward the provider and the PE-CE protocol.
- Core with IGP and MPLS: OSPF on every provider router, with LDP on top to discover neighbors, form adjacencies and assign labels.
- iBGP following the BGP free core paradigm: a single session between PE-1 and PE-2, loopback to loopback. The P routers do not run BGP.
- VPNv4 and VRFs: MP-BGP carries the customer prefixes between the PEs as VPNv4 prefixes, and each VRF decides what it imports.
A detail from the class: after step 2 you already have an MPLS core with transparent tunnels. You could carry two customer eBGP sessions over the LDP core without any L3VPN. L3VPN is the de facto standard and the most scalable option, but not the only way to build tunnels with MPLS.
This is what step 3 looks like on PE-1. The VPNv4 address family enables MP-BGP, and send-community both lets the extended communities travel:
! Step 3: iBGP only between the PEs, sourced from Loopback0
PE-1(config)# router bgp 100
PE-1(config-router)# bgp router-id 1.1.1.1
PE-1(config-router)# neighbor 4.4.4.4 remote-as 100
PE-1(config-router)# neighbor 4.4.4.4 update-source Loopback0
! MP-BGP: carry VPNv4 prefixes and extended communities (route target)
PE-1(config-router)# address-family vpnv4 unicast
PE-1(config-router-af)# neighbor 4.4.4.4 activate
PE-1(config-router-af)# neighbor 4.4.4.4 send-community both
Peer-to-peer VPN versus overlay
IPsec is an overlay VPN. The customer builds the tunnel from its firewall to the other site, across the internet. The provider only carries encrypted packets: it neither sees nor exchanges the customer's routes.
MPLS L3VPN is a peer-to-peer VPN; Cisco describes it as a peer model. The provider tells the customer: “give me your routes”. The CE advertises them to the PE, and the PE stores them and carries them across its network to the other site.
| Overlay (IPsec) | Peer-to-peer (MPLS L3VPN) | |
|---|---|---|
| Who builds the VPN | The customer, end to end | The provider, between its PEs |
| Customer routes | The provider does not see them | The PE learns them and stores them in a VRF |
| Where it travels | Usually over the internet | Over the provider's MPLS core |
| Encryption | Yes | Not by itself: isolation comes from VRFs and labels |
VRF: one virtual router per customer
If the PE kept every customer's routes in its global table, they would mix with the provider's routes and with each other. Two customers using the same 192.168.1.0/24 network would collide.
The VRF (Virtual Routing and Forwarding) solves this. It is a virtual router instance inside the PE, with its own routing table and its own CEF table. The interface toward the customer becomes part of that VRF. The PE has as many VRFs as customers it connects through L3VPN, within what the hardware supports.
On the whiteboard it shows as two layers. The provider has its native control plane for OSPF, BGP and MPLS. Each VRF creates a separate control plane and forwarding plane for one customer.
In the lab, the Customer A VRF is called TU-CA1 on PE-1 and TU-CA2 on PE-2:
! PE-1: VRF for customer A, site 1
PE-1(config)# ip vrf TU-CA1
PE-1(config-vrf)# rd 300:300
PE-1(config-vrf)# route-target both 3:3
PE-1(config-vrf)# exit
PE-1(config)# interface GigabitEthernet0/1
PE-1(config-if)# ip vrf forwarding TU-CA1
! ip vrf forwarding removes the interface IP address: set it again
PE-1(config-if)# ip address 192.168.1.1 255.255.255.0
PE-1(config-if)# no shutdown
! PE-2: VRF for customer A, site 2 (different RD, same RT)
PE-2(config)# ip vrf TU-CA2
PE-2(config-vrf)# rd 400:400
PE-2(config-vrf)# route-target both 3:3
PE-2(config-vrf)# exit
PE-2(config)# interface GigabitEthernet0/1
PE-2(config-if)# ip vrf forwarding TU-CA2
PE-2(config-if)# ip address 192.168.2.1 255.255.255.0
! Verify
PE-1# show ip vrf
PE-1# show ip route vrf TU-CA1
ip vrf syntax with ip vrf forwarding. Current IOS and IOS XE also offer vrf definition with vrf forwarding, which is what recent Cisco examples show. Both create a VRF; the newer one supports several address families.Route distinguisher and route target
RD: making the prefix unique
Inside the VRF you configure the route distinguisher (RD). It is an 8-byte value prepended to the IPv4 prefix. The result is a 12-byte VPNv4 prefix: RD plus prefix. That way, the same 192.168.1.0/24 from two different customers becomes two different VPNv4 prefixes inside BGP.
Top, the VPNv4 prefix; bottom, the route target decides which VRF imports the route. Diagram: The House of Routing.
The RD is not a label and does not identify the VPN. According to RFC 4364, its only purpose is to create distinct routes for the same IPv4 prefix. That is why, in the lab, Customer A's VPN uses rd 300:300 on PE-1 and rd 400:400 on PE-2, and it works.
RT: deciding who imports
What takes 30.30.30.30 from CE-A1 to CE-A2, and 40.40.40.40 the other way, is the route target (RT). The RT is a BGP extended community that travels with each VPNv4 prefix:
- Export: the PE tags the routes leaving the VRF with these RTs.
- Import: the PE accepts into the VRF the routes that carry one of these RTs.
- Both: export and import with the same value. This is what the lab uses:
route-target both 3:3on both VRFs.
That is why the PEs need send-community both on the VPNv4 session. Without the extended communities, the RT does not travel and no VRF imports anything. Cisco's guide marks it as mandatory.
A prefix can carry several RTs, but only one RD. That difference sets up the troubleshooting at the end of Day 1: the RT is the key to the service.
Two labels and four tables
Now put the pieces together. When PE-1 receives a packet from CE-A1 toward 40.40.40.40, it adds two labels:
- The VPN label (inner label): PE-2 advertised it through MP-BGP along with the VPNv4 prefix. It will tell PE-2 which VRF the packet goes to.
- The transport label (outer label): LDP advertised it for PE-2's loopback 4.4.4.4, the BGP next hop. It carries the packet across the core.
Cisco's guide sums it up: the top label directs the packet to the correct PE router, and the second label tells that PE how to forward the packet to the CE. That is why the P routers do not need to know the customer routes: they only see the transport label.
| Plane | IP | MPLS |
|---|---|---|
| Control | RIB | LIB (label information base) |
| Forwarding (data plane) | FIB, managed by CEF | LFIB (label forwarding information base), which depends on CEF |
From a BGP core to LDP tunnels
To understand why MPLS was born, the whiteboard compares two cores. In a traditional BGP core, the provider shares its control plane and data plane with the customer traffic. Every core router learns the customer routes through iBGP, in a single global table.
Because iBGP does not pass routes learned from one iBGP neighbor to another, there are two ways out: route reflectors or a full mesh. A full mesh needs n(n-1)/2 sessions; with 10 routers, that is 45. And every core router ends up with the whole internet table, some 800 000 routes at the time of the class.
Providers asked themselves: does the core really need all those routes to connect one site to another? From that question comes the idea of ingress and egress: what matters is entering at one edge and leaving at the other. It makes no difference whether there are 4 routers or 700 in the middle.
GRE: one tunnel per pair
One option is a GRE tunnel between loopbacks: interface Tunnel0, the loopback as the source and an iBGP session inside. It works, but it does not scale. Each pair of edge routers needs its own tunnel, and you have to create and maintain them one by one.
LDP: tunnels that build themselves
With LDP, the whole core speaks in labels. OSPF and LDP have already formed the neighbor relationships, so every router knows which label to use to reach each loopback. When the ingress PE imposes the labels, the packet follows the label path to the egress PE, with no interface Tunnel at all.
If you add a router with a new prefix, LDP assigns it labels and the prefix joins the “universe of labels” automatically. As long as the IGP is healthy, the core grows without touching any tunnels. That is the transparent tunnel.
Class videos
This chapter goes with the second video of Day 1: the whiteboard before the lab. Recorded live on March 13, 2021, with Spanish audio and subtitles in Spanish, English, French and Portuguese.
Recorded live; Spanish audio with Spanish, English, French and Portuguese subtitles. When you play it, the video loads from YouTube. Day 1 playlist on YouTube
Test what you learned
1. Does MPLS run on the link between the CE and the PE?
Answer. No. MPLS lives only inside the provider core. Between the CE and the PE runs whatever protocol they agree on, such as OSPF, EIGRP, eBGP or static routes, and the PE interface belongs to the customer's VRF.
2. Two customers use the 192.168.1.0/24 network. What keeps them from colliding inside BGP?
Answer. The route distinguisher. Each VRF prepends its RD to the prefix, so BGP sees two different VPNv4 prefixes. On the PE, each customer also lives in its own VRF.
3. PE-1 uses rd 300:300 and PE-2 uses rd 400:400 for the same customer. Does the VPN work?
Answer. Yes. The RD only makes prefixes unique. What decides which VRF imports a route is the route target, and both VRFs use route-target both 3:3.
4. What happens if you forget send-community both on the VPNv4 session?
Answer. The extended communities do not travel, so the route target never reaches the other PE. No VRF imports the routes, and the VPN does not work.
5. Why don't P1 and P2 need BGP?
Answer. Because customer packets cross the core with a transport label toward the egress PE's loopback. The P routers only switch that label with OSPF and LDP: that is the BGP free core.
Key takeaways
- The lab: PE-1, P1, P2 and PE-2 in a line, with /32 loopbacks, /30 links and one label range per router.
- The customer is agnostic to the core: any protocol can run between CE and PE, and there is no MPLS toward the CE.
- Four steps: CEs, a core with OSPF and LDP, iBGP only between PEs and, finally, VPNv4 with VRFs.
- MPLS L3VPN is a peer-to-peer VPN: the provider stores the customer routes in a VRF.
- VPNv4 = 8-byte RD + IPv4 prefix. The RD makes the prefix unique; the route target decides who imports it.
- Without send-community both the route target does not travel, and without a route target there is no VPN.
- LDP builds transparent tunnels that scale without configuring a GRE tunnel for every pair of routers.
Official resources
- Cisco · Configure a Basic MPLS VPN Networkcisco.com
- Cisco · Configuring MPLS Layer 3 VPNscisco.com
- RFC 4364 · BGP/MPLS IP VPNsrfc-editor.org
- RFC 3031 · MPLS Architecturerfc-editor.org
- Cisco · Configuring Basic MPLS Using OSPFcisco.com
Source and credits. Chapter written from the MPLS Masterclass that Jesús Espinoza recorded live in March 2021. Text drafted with AI assistance and reviewed; original diagrams by The House of Routing. Technical data and configuration were checked against official Cisco documentation and IETF RFCs.