Label stack, LDP, and MP-BGP VPNv4/VPNv6

Two customers both use 10.1.0.0/16, and nothing in the IP header says whose 10.1.1.1 it is. The PE answers by interface: each is bound to a customer's VRF. Label switching reads the Layer 3 header once, at the edge. LDP labels the paths the IGP chose. An 8-byte route distinguisher makes identical prefixes distinct, route targets decide which VRFs import them, and MP-BGP carries them between PEs.

In Daveth Pro (Network)7 min video · lab: MPLS L3VPN

By , founder of Daveth · Updated

Opening frame of the video walkthrough of Label stack, LDP, and MP-BGP VPNv4/VPNv6

Watch this lesson

7 min · Video walkthrough

In Daveth Pro (Network)

The full 7 min walkthrough is in Daveth Pro (Network). See what the plan opens

Upcoming practical lab

Lab C11: MPLS L3VPN

What the lab covers

What this page answers

What is the difference between a route distinguisher and a route target?

The route distinguisher is an 8-byte value added to a prefix to make it a unique VPN-IPv4 prefix. The route target is an extended community that decides which VRFs import the route: uniqueness against membership. Read it in “Problem two: deciding who gets it”

What does LDP do in MPLS?

It distributes labels hop by hop for routes the underlying IGP has chosen. It computes no path of its own, so it inherits whatever path the IGP picked. Read it in “LDP puts numbers on a path it did not choose”

How do you configure MP-BGP VPNv4 between PEs?

Define the iBGP neighbour once under router bgp, then activate it under address-family vpnv4, and under vpnv6 for IPv6. One session carries each family, switched on separately. Read it in “One session, one address family, two separate events”

Whose 10.1.1.1?

One provider edge router. Two customers plugged into it, and both of them use 10.1.0.0/16 internally, because everybody uses ten.

A packet arrives on that router with a destination of 10.1.1.1. Whose is it? Look at every field in an IP header and there is no customer identifier in any of them. The address is the same address for both.

State 1 Two customers, one edge, one core

Which of these seven routers needs to know whose packet this is?

Network drawing: CE1, AS 65001 · SITE A, CE3, AS 65010 · CUSTOMER B, PE1, PROVIDER EDGE, Lo0 10.0.0.1, P1, CORE, P2, PE2, Lo0 10.0.0.4, CE2, AS 65001 · SITE B

Four provider routers in a line. The two at the ends are provider edge routers, where customers attach; the two in the middle are P routers, and "P devices do not maintain any VPN routes." That is not a limitation: it is the design, and it "increases the scalability of the provider's core".

Which sets the question the rest of this page answers: how does a packet cross a network that has never heard of the customer it belongs to?

The interface is the answer

Read the documentation's definition of a provider edge router and watch which noun does the work: a device that attaches the VPN label to incoming packets based on the interface or sub-interface on which they are received.

The customer's identity is not carried in the packet. It is a property of where the packet came in. Bind an interface to a customer and every packet arriving on it is that customer's by definition, with nothing to spoof and nothing to look up.

PE1(config)# vrf definition CUST_A
PE1(config-vrf)# rd 100:1
PE1(config-vrf)# route-target both 100:1
PE1(config-vrf)# interface GigabitEthernet0/0
PE1(config-if)# vrf forwarding CUST_A
PE1(config-if)# ip address 192.168.11.1 255.255.255.252

A customer-site VRF "contains all the routes available to the site from the VPNs of which it is a member", and, by omission, none of anybody else's. It is not a filter on a shared table. It is a separate table, and the PE holds one per customer.

PE1# show ip vrf
  Name                             Default RD          Interfaces
  CUST_A                           100:1               Gi0/0
  ! one customer, one table, one interface
  CUST_B                           100:2               Gi0/1
  ! and another, which shares nothing with it

State 2 The same prefix, arriving twice

Two customers advertise the identical prefix into the same router. What stops them colliding?

Network drawing: CE1, AS 65001 · SITE A, CE3, AS 65010 · CUSTOMER B, PE1, PROVIDER EDGE, 10.1.0.0/16, CUST_A, CUST_B

Nothing had to stop them, because they were never in the same table. The sessions are eBGP: the provider's AS on one side, the customer's on the other, and each is configured inside its own customer's address family:

PE1(config)# router bgp 100
PE1(config-router)# address-family ipv4 vrf CUST_A
PE1(config-router-af)# neighbor 192.168.11.2 remote-as 65001
PE1(config-router-af)# neighbor 192.168.11.2 activate
PE1(config-router-af)# exit-address-family

The same router has another block just like it for the next customer, with its own neighbour in its own AS, and the two cannot see each other.

Who chose BGP? The customer did. Configure the PE device with the same routing protocol that the CE device uses: BGP, RIPv2, EIGRP, OSPF or static. That is unusual, because a provider normally dictates its own interfaces, and it follows from what the service is: the customer is buying transport for their routing, so the routing has to be theirs.

Two spellings, and this course cannot reconcile them. You will meet the interface command as vrf forwarding and as ip vrf forwarding, with the VRF created by either vrf definition or ip vrf. Both appear in the pages this course consulted and no page consulted explains the difference or says one supersedes the other. This page uses the first form because it is the one the IPv6 chapter builds on. Establish the rule for your platform before an exam does it to you.

Analyze the header once, at the edge

A packet crossing four routers gets four routing-table lookups, each one taking the destination address, finding the longest match and deciding an outgoing interface. Every router repeats work every router before it already did.

Label switching analyzes the Layer 3 header only once at the network edge, then swaps labels at each MPLS switch, and refers to the MPLS forwarding table for the next hop. Conventional forwarding analyzes the Layer 3 header independently at each switch.

Two rows of that comparison would still matter if MPLS were no faster than IP at all, and they are not the speed ones. The first is that the label assignment may consider more than just the Layer 3 header, for example, routing policy: the edge can decide on anything it likes, and the rest of the network just follows. The second names the mechanism:

Forwarding equivalence class: a set of packets treated identically for forwarding, represented by the same label.

A label is not a destination. It names a group of packets that will be treated the same. Sit with that, because it is a bigger idea than compression, and it is why MPLS ended up carrying VPNs rather than merely going fast.

LDP puts numbers on a path it did not choose

LDP provides a standard methodology for hop-by-hop, or dynamic label, distribution in an MPLS network by assigning labels to routes that have been chosen by the underlying Interior Gateway Protocol.

It runs no algorithm, computes no path, and has no view about which way traffic should go. It waits for the IGP to decide and then puts numbers on the answer. Which means it inherits every problem the IGP has: an IGP path you did not want becomes an LSP you did not want, and nothing in LDP will tell you, because from LDP's point of view it worked perfectly.

What it exchanges is modest. An LDP label binding is an association between a destination prefix and a label: a prefix and a number, and nothing else in the message.

MPLS is enabled in two places, globally and per interface, which is the same two-switch shape multicast had. After the global half only:

PE1# show mpls ldp neighbor

Nothing. Then the per-interface half, on both ends of each core link, and now two commands, because there are two stages. Discovery first:

P1# show mpls ldp discovery
Local LDP Identifier:
    10.0.0.2:0
    ! the label space, named by a loopback rather than by an interface
    Discovery Sources:
    Interfaces:
        GigabitEthernet0/0 (ldp): xmit/recv
        ! xmit and recv: hellos in both directions on this wire
            LDP Id: 10.0.0.1:0
        GigabitEthernet0/1 (ldp): xmit/recv
            LDP Id: 10.0.0.3:0

Then the session, which is a different thing with a different requirement:

P1# show mpls ldp neighbor
    Peer LDP Ident: 10.0.0.1:0; Local LDP Ident: 10.0.0.2:0
    ! one neighbour on each side, and a label space named by a loopback
        State: Oper
    Peer LDP Ident: 10.0.0.3:0; Local LDP Ident: 10.0.0.2:0
        State: Oper

Proves: the first proves hellos are being exchanged on that interface. The second proves a session exists over which bindings can actually be sent.
Does not prove: neither proves the LSP goes anywhere useful, because LDP labels whatever the IGP chose. And the first does not prove the second: discovery happens on the wire, while the session is TCP to an address, and an address has to be routable, which is why a loopback that the IGP is not carrying gives you discovery that succeeds and a session that never forms.

State 3 One destination, three different numbers

Follow the far PE's loopback across three routers. What changes, and what does not?

Network drawing: PE1, P1, P2, PE2, Lo0 10.0.0.4, push 22, swap 22 → 47, pop, one hop early
P1# show mpls forwarding-table
Local      Outgoing   Prefix           Bytes Label  Outgoing   Next Hop
Label      Label      or Tunnel Id     Switched     interface
20         Pop Label  10.0.0.1/32      0            Gi0/0      10.1.12.1
21         Pop Label  10.0.0.3/32      0            Gi0/1      10.1.23.2
22         47         10.0.0.4/32      0            Gi0/1      10.1.23.2
! in 22, out 47: two different routers' private numbers for one destination

The LFIB is a data structure in which destinations and incoming labels are associated with outgoing interfaces and labels. Count the columns that definition names: four. That is the swap, written down as a table.

And here is the reason the swap exists at all, which no page says outright: a label is locally significant. It means something only to the router that advertised it. P1 tells PE1 send me that destination with 22, P2 tells P1 "use 47", so P1 swaps one private number for another. A value that meant the same thing everywhere would never need swapping.

Problem one: making identical prefixes different

Those customer prefixes have to travel between provider edge routers, through BGP, which carries one copy of a prefix and picks a best path. Two identical prefixes, one BGP table.

After the PE device learns the IP prefix, the PE converts it into a VPN-IPv4 prefix by combining it with an 8-byte route distinguisher. Eight bytes bolted onto the front, and now BGP has two distinct things to carry rather than one contested one.

It exists because the address itself cannot be trusted to be unique: the RD uniquely identifies the customer address, even if the customer site is using globally nonunique (unregistered private) IP addresses.

Now the important part, and it is a negative. Ask what the route distinguisher decides about where the route goes.

Nothing. It has made the prefix unique and that is its entire job. A VPNv4 prefix with a perfectly good RD and nothing else reaches no customer table anywhere. Uniqueness and distribution are different questions, and the RD answers only the first.

Problem two: deciding who gets it

Route target extended community attributes are used to identify a set of sites and VPN routing and forwarding instances that can receive routes with a configured route target. Read that against the RD's job and notice they share nothing: this is membership, and that was uniqueness.

The mechanism is a pair of lists. A VRF exports a route target, stamping it onto every route it advertises, and imports a set of them, accepting any route carrying one. The import list defines route target extended community attributes that a route must have in order for the route to be imported into the VRF. Two independent lists, and a route moves from one customer table to another only when one PE's export matches another PE's import.

PE1(config)# vrf definition CUST_A
PE1(config-vrf)# rd 100:1
PE1(config-vrf)# route-target both 100:1

Look at those two lines again. What do they have in common? Nothing except the digits. The same numbers, twice, doing two unrelated jobs, and almost every configuration you will read does this, because it is readable and because there is no reason not to.

It is also why so many engineers believe the two are the same thing. Change the route distinguisher and the route is still distributed to exactly the same tables. Change the route target and the route goes somewhere else entirely while remaining just as unique. The RD makes it unique. The RT decides who gets it.

One session, one address family, two separate events

BGP propagates reachability information for VPN-IPv4 prefixes among PE devices by means of the BGP multiprotocol extensions: BGP carrying an address family that is not IPv4 unicast, which is what the MP in MP-BGP means. Between PEs these are iBGP sessions.

PE1(config)# router bgp 100
PE1(config-router)# neighbor 10.0.0.4 remote-as 100
PE1(config-router)# address-family vpnv4
PE1(config-router-af)# neighbor 10.0.0.4 activate
PE1(config-router-af)# exit-address-family

The neighbour is defined once and activated per address family. One session can carry VPNv4, VPNv6 and ordinary IPv4 unicast, each switched on separately, and forgetting the activate gives you a session that comes up and carries nothing of that kind, which looks exactly like a routing problem and is not one.

PE1# show bgp vpnv4 unicast all
Route Distinguisher: 100:11
! the far end's route distinguisher: what made this prefix unique
 *>i 10.2.0.0/16      10.0.0.4          100  65001 i
      Extended Community: RT:100:1
      ! and the route target it carries: what decides who gets it
      mpls labels in/out nolabel/91
 ! the service label the far PE bound to this prefix, travelling with it

Then, milliseconds later and on the same router, a second thing happens:

PE1# show ip route vrf CUST_A
Codes: B - BGP

B        10.1.0.0/16       [20/0] via 192.168.11.2
B        10.2.0.0/16       [200/0] via 10.0.0.4
! imported, because the route target matched this table's import list

Proves: the first command proves the VPNv4 prefix reached this router's BGP table, with its route distinguisher and the route targets it carries. The second proves it was imported into that customer's table, which is a separate event.
Does not prove: the first does not prove any table wanted the route, and the second does not exist if the first failed. The gap between them is the import decision, and no single command spans it, which is why a route target problem shows up as two outputs that disagree.