MPLS MASTERCLASS · CHAPTER 5

The end-to-end L3VPN and the label stack

We finish Customer A's VPN, validate it from the CE and follow a packet with its two labels across the whole core.

15 min readVideo: Day 1, part 6Level: intermediate to advanced

From point A to point B

Point A: you have the core running OSPF and LDP, the iBGP session with VPNv4 between PE-1 and PE-2, and VRF TU-CA1 speaking OSPF with its CE. But Customer A still can't reach the other side. Point B: by the end of this chapter your L3VPN will work end to end, you'll know how to read a VPNv4 prefix and you'll be able to explain, label by label, how a packet crosses the core while the P routers know nothing about the customer's routes.

What you'll see
  1. Redistributing OSPF into BGP inside the VRF
  2. How to read a VPNv4 prefix and its extended attributes
  3. The VRF on PE-2 and the validation from the CE
  4. The VPN label and the transport label, with PHP
  5. The MPLS header and its effect on the MTU

Redistributing OSPF into BGP per VRF

PE-1 already had the bridge from BGP into OSPF: redistribute bgp 100 subnets under router ospf 20 vrf TU-CA1. The opposite path is missing. The routes CE-A1 advertises through OSPF have to enter BGP to travel to the other PE.

The key is where you configure it. Not in the general IPv4 unicast address family, but in address-family ipv4 vrf TU-CA1. There you tell BGP: take OSPF 20 that belongs to this VRF, and only that one.

PE-1# configure terminal
PE-1(config)# router bgp 100
PE-1(config-router)# address-family ipv4 vrf TU-CA1
PE-1(config-router-af)# redistribute ospf 20 vrf TU-CA1
PE-1(config-router-af)# end
PE-1# show run | section bgp

In class we called this the most intricate part of the whole process, and for good reason: you have three nested contexts (BGP, the VRF's address family and that VRF's OSPF process). Pick the wrong context and the routes stay inside the VRF and never reach the core.

Remember that this rests on what we built earlier: the VPNv4 address family activated toward the other PE, and communities being sent.

! Built in the previous chapter: without it the RT never leaves PE-1
router bgp 100
 address-family vpnv4 unicast
  neighbor 4.4.4.4 activate
  neighbor 4.4.4.4 send-community both

VPNv4 prefixes and extended attributes

After redistributing, try show ip bgp. It's empty. That's not an error: the router no longer has native BGP prefixes, it has VPNv4 prefixes. To see them you ask for their address family.

PE-1# show ip bgp
! empty: there are no native IPv4 BGP prefixes
PE-1# show bgp vpnv4 unicast all
PE-1# show bgp vpnv4 unicast rd 300:300
PE-1# show bgp vpnv4 unicast vrf TU-CA1 30.30.30.30/32

With all you see every VRF. With rd 300:300 you filter by Customer A's route distinguisher on this PE. With vrf TU-CA1 and a prefix you get the details of one route. A real PE can hold hundreds of VRFs, so filtering is not a luxury.

The details of 30.30.30.30/32 tell the whole story:

  • Route distinguisher 300:300. It turns the IPv4 route into a unique VPNv4 prefix, even if another customer uses the same address.
  • Next hop 192.168.1.2. CE-A1, where the route came from. Origin: redistributed.
  • Extended community RT:3:3. The route target we set on the VRF.
  • OSPF domain ID. The OSPF process number encoded in hexadecimal (20 is 0x14). Something that was always local in OSPF now travels as an attribute.
  • OSPF route type. Area, route type and options. It says whether the route was born inside the area (LSA type 1 or 2), between areas (type 3) or as an external (type 5).
  • OSPF router ID. The 0.0.0.1 we configured in the VRF's OSPF.

Carrying OSPF information through BGP required new extended attributes. That's why send-community both (or extended) is mandatory: without it, the route target and the OSPF attributes never leave the PE and the other side imports nothing. Cisco marks it as mandatory in its basic MPLS VPN guide, and RFC 4577 defines these OSPF attributes.

Good to know. RFC 4577 calls that field the OSPF Route Type: 1 or 2 for intra-area routes, 3 for inter-area, 5 for external and 7 for NSSA. IOS shows it as OSPF RT; don't mistake it for a route tag.

The other end: the VRF on PE-2

If you go to PE-2 and run show bgp vpnv4 unicast all, there is still nothing useful: no VRF exists to import those routes. Time to repeat PE-1's pattern with PE-2's own values.

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
PE-2(config-if)# exit
PE-2(config)# do ping vrf TU-CA2 192.168.2.2

Look at the numbers. The RD changes (400:400 versus 300:300) because it identifies the VRF on each PE. The route target is the same (3:3) because it's what ties Customer A's two sites together. The RD distinguishes; the RT connects.

Then the VRF's OSPF toward CE-A2 and the mutual redistribution:

PE-2(config)# router ospf 20 vrf TU-CA2
PE-2(config-router)# router-id 0.0.0.2
PE-2(config-router)# network 192.168.2.0 0.0.0.255 area 0
PE-2(config-router)# redistribute bgp 100 subnets
PE-2(config-router)# exit
PE-2(config)# router bgp 100
PE-2(config-router)# address-family ipv4 vrf TU-CA2
PE-2(config-router-af)# redistribute ospf 20 vrf TU-CA2
PE-2(config-router-af)# end
PE-2# show ip vrf
PE-2# show ip route vrf TU-CA2
PE-2# write

Something instructive happened in class. Before configuring OSPF-into-BGP redistribution on PE-2, VRF TU-CA2 already showed 30.30.30.30 and 31.31.31.31. That makes sense: the half going from PE-1 to PE-2 was already complete. Route 30.30.30.30 was born in OSPF but reached PE-2 through iBGP. The return path was missing, and that's why PE-1 didn't see 40.40.40.40 yet.

Validating from the CE

The CE knows nothing about MPLS. It only speaks OSPF with its PE. That's why the real test is done from the CE:

CE-A1# show ip route
CE-A1# ping 40.40.40.40
CE-A1# ping 41.41.41.41
CE-A1# traceroute 40.40.40.40 source 30.30.30.30 ttl 1 10

CE-A2 receives 30.30.30.30 and 31.31.31.31 as OSPF routes, and CE-A1 receives 40.40.40.40 and 41.41.41.41. The loopback-to-loopback ping answers: there is end-to-end connectivity. The traceroute also shows the labels at each hop:

HopRouterLabels shownWhat happened
1PE-1noneNative IP arrives at VRF TU-CA1
2P1 (10.10.10.2)202/405PE-1 pushed 405 (VPN) and 202 (transport) on top
3P2302/405P1 swapped 202 for 302; 405 stays the same
4PE-2405P2 removed the transport label (PHP)
5CE-A2nonePE-2 removed 405 and delivered clean IP

The two-label stack

That traceroute is the whole L3VPN in five lines. Every customer packet crosses the core with two labels, and each one has a different job.

Two-label stack from PE-1 to PE-2 A packet from CE-A1 (30.30.30.30) to CE-A2 (40.40.40.40) enters PE-1 as plain IP. PE-1 pushes the VPN label 405 and, on top, the transport label 202 learned from P1 by LDP. P1 swaps 202 for 302 and leaves 405 untouched. P2 is the penultimate hop: PE-2 advertised implicit-null for 4.4.4.4, so P2 pops the transport label and sends only 405. PE-2 pops 405, looks up VRF TU-CA2 and delivers a plain IP packet to CE-A2. CE-A130.30.30.30 PE-11.1.1.1 · 100-199 P12.2.2.2 · 200-299 P23.3.3.3 · 300-399 PE-24.4.4.4 · 400-499 CE-A240.40.40.40 IP 202 · S=0 405 · S=1 IP 302 · S=0 405 · S=1 IP 405 · S=1 IP IP OPERATION push 405 (VPN) push 202 (LDP) swap 202 → 302 405 untouched pop 302 (PHP) implicit-null pop 405 VRF TU-CA2 lookup outer label · transport (LDP) inner label · VPN (MP-BGP) customer IP packet P1 and P2 never look up 40.40.40.40: they only read the top label. The VPN label 405 is created by PE-2 and stays the same from PE-1 to PE-2.

PE-1 pushes two labels, P1 swaps only the top one, P2 removes it and PE-2 removes the VPN label. Diagram: The House of Routing.

  • The VPN label (inner label), 405. PE-2 creates it and advertises it through MP-BGP along with the VPNv4 prefix. It tells PE-2 which VRF the packet belongs to. It never changes along the way.
  • The transport label (outer label), 202 and then 302. It comes from LDP and carries the packet to the BGP next hop, loopback 4.4.4.4. This is the label that gets swapped at each P router.
Where each label comes from Control plane of the lab. Above, PE-2 sends PE-1 an MP-BGP VPNv4 update for 400:400:40.40.40.40/32 with next hop 4.4.4.4, VPN label 405 and extended communities: route target 3:3, OSPF domain ID, OSPF route type and router ID. Below, LDP advertises labels for 4.4.4.4/32 from right to left: PE-2 sends implicit-null to P2, P2 sends 302 to P1, and P1 sends 202 to PE-1. PE-1 combines both: it pushes 405 and then 202. MP-BGP · VPNv4 (iBGP AS 100, loopback to loopback) 400:400:40.40.40.40/32 · next hop 4.4.4.4 · VPN label 405 RT:3:3 · OSPF DOMAIN ID · OSPF RT (area:type:options) · OSPF ROUTER ID PE-2 → PE-1 (P routers only forward the TCP session) PE-1 1.1.1.1 P1 2.2.2.2 P2 3.3.3.3 PE-2 4.4.4.4 LDP · LABELS FOR 4.4.4.4/32 imp-null 302 202 Result on PE-1: push 405 (from BGP), then push 202 (from LDP) toward next hop 4.4.4.4

MP-BGP supplies the VPN label; LDP supplies the transport label. PE-1 combines both. Diagram: The House of Routing.

Why does the packet reach PE-2 with only 405? Because of penultimate hop popping (PHP). PE-2 advertises the implicit-null label for its loopback 4.4.4.4 through LDP. P2, the penultimate hop, reads it as “remove the transport label before sending”. In P2's show mpls forwarding-table you see it as Pop Label for 4.4.4.4/32. So PE-2 does a single lookup: it reads 405, knows it means VRF TU-CA2 and hands the IP packet to CE-A2.

The operations have names: push (or impose) at the ingress PE, swap at the P routers, pop at the penultimate hop and a final pop (dispose) at the egress PE, the router that created the VPN label.

The same thing shows up in the capture we took on the PE-1 to P1 link. A ping from PE-1 to 4.4.4.4 leaves with label 202, but the reply comes back unlabeled. Same reason: for its connected network, P1 advertises implicit-null, so it does PHP before delivering to PE-1. You confirm it with show mpls ldp bindings on P1.

P1# show ip route 40.40.40.40
! no route: the core does not know customer prefixes
P1# ping 40.40.40.40
! fails for the same reason
P1# show mpls forwarding-table
P1# show mpls ldp bindings

The MPLS header bit by bit

In Wireshark the label sits between the Ethernet header and the IP header. That's why MPLS is called a “layer 2.5” protocol. The capture also shows the LDP hellos.

MPLS label stack entry and overhead On the wire the labels sit between the Ethernet header and the IP header: first the transport label 202 with the bottom-of-stack bit at 0, then the VPN label 405 with the bottom-of-stack bit at 1. Each label stack entry is 32 bits: 20 bits of label, 3 bits of traffic class (formerly EXP, used for QoS), 1 bottom-of-stack bit and 8 bits of TTL. Each label adds 4 bytes, so two labels add 8 bytes to a 1500-byte IP packet. FRAME ON THE PE-1 → P1 LINK Ethernet label 202 label 405 IP header payload FCS ONE LABEL STACK ENTRY · 32 BITS Label · 20 bits TC/EXP · 3 S TTL · 8 bits bit 019 20-2223 24-31 values 0-15 reserved · 3 = implicit-null QoS bottom of stack hop limit 4 bytes per label · 2 labels = 8 bytes 1500-byte IP packet + 8 bytes of labels = 1508 bytes of MPLS payload on each core link

Each stack entry takes 32 bits. The S bit marks the last one. Diagram: The House of Routing.

FieldBitsWhat it does
Label20The label value. 0 to 15 are reserved; 3 is implicit-null and never travels on the wire
EXP3Experimental bits, used in practice to mark quality of service (QoS)
S1Bottom of stack: set to 1 on the last label in the stack
TTL8Time to live, as in IP. It can be hidden so the core hops don't show

In our stack, 202 carries S=0 because another label sits below it, and 405 carries S=1 because it's the last one before the IP header.

The provider as a super cable

Try this on P1: ping 40.40.40.40. It fails. And show ip route 40.40.40.40 returns nothing. P1 doesn't know the customer's routes, and it has no reason to.

That's the idea we want you to keep: the provider is a super cable. It connects a user in Spain with another in Colombia, or one in Mexico with another in Argentina, and the core doesn't need to know where the destination is. It just moves the packet to the edge PE, and the PE takes care of delivering it. RFC 4364 puts it this way: the backbone doesn't even need routes to the CEs, only to the PEs.

This breaks the model we learn in CCNA. In traditional routing, each router de-encapsulates the frame, looks at the destination IP, checks the RIB with the longest-match rule and lets CEF re-encapsulate. With MPLS, the core router reads the label, checks its label table and switches. It doesn't look at the IP packet to decide. The IGP and LDP already did that work when they built the paths.

MTU: 4 bytes per label

Each label adds 4 bytes. An L3VPN carries two, so a 1500-byte IP packet takes 1508 bytes on the core links. If a core interface stays at 1500, that packet doesn't fit.

Per RFC 3032, if the labeled packet is too big and has the DF bit set, the router drops it and sends an ICMP “fragmentation needed”. Path MTU Discovery helps if that ICMP reaches the source, but the cleanest fix is to design the core with headroom.

  • Cisco recommends that core-facing interfaces have a higher MTU than customer-facing interfaces, so the labels fit.
  • The mpls mtu command can't exceed the interface MTU. If you try, IOS asks you to raise the interface MTU first.
  • The MTU must match on both ends of every link: OSPF and IS-IS require it to form an adjacency.
Do the math. A basic L3VPN carries 2 labels (8 bytes). If you also use Traffic Engineering or fast protection, the stack grows. Size the MTU for the worst case, not for the lab.

Class videos

This chapter goes with the sixth part of the first marathon. It is a live session recorded with Cisco routers in GNS3, with audio in Spanish 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. Why is show ip bgp empty on PE-1 if BGP already has the customer's routes?

Answer. Because those routes aren't native IPv4 prefixes but VPNv4 prefixes (RD plus prefix). They live in another address family and you see them with show bgp vpnv4 unicast all, by RD or by VRF.

2. The traceroute shows 202/405 and then 302/405. Which one is the VPN label, and why doesn't it change?

Answer. 405. PE-2 created it for VRF TU-CA2 and advertised it through MP-BGP. The P routers only look at the top label, the transport one, so 405 reaches PE-2 untouched.

3. Who removes the transport label, and what triggers it?

Answer. P2, the penultimate hop. PE-2 advertised implicit-null for 4.4.4.4 through LDP, which tells P2 to pop before sending (penultimate hop popping).

4. You ping 40.40.40.40 from P1 and it fails. Is the VPN broken?

Answer. No. P routers don't hold customer routes; they only switch labels. The valid test is from the CE, or with ping vrf from the PE.

5. The core links have an MTU of 1500. What happens to a 1500-byte customer IP packet with DF set?

Answer. With two labels it weighs 1508 bytes and doesn't fit. With DF set it's dropped and the router sends an ICMP fragmentation-needed message. The fix is to raise the core MTU.

Key takeaways

  • OSPF-into-BGP redistribution goes inside address-family ipv4 vrf, with that VRF's OSPF process.
  • VPN routes are VPNv4 prefixes: they carry an RD, a route target and, with OSPF, the domain ID, route type and router ID.
  • Without send-community both or extended, extended attributes don't travel and nothing is imported.
  • The RD changes on each PE; the route target is what ties the customer's sites together.
  • The VPN label never changes; the transport label is swapped at each P and removed at the penultimate hop.
  • P routers don't know customer routes: the provider is a super cable.
  • Each label adds 4 bytes; design the core MTU with headroom.

Official resources

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.

Navigate