NET · Guide · MPLS Masterclass

The 30 most important MPLS commands

A practical guide to the 30 Cisco IOS and IOS XE commands you need to configure and verify MPLS: LDP, labels, VRF, MP-BGP VPNv4, L3VPN, pseudowire and VPLS.

Illustration of an MPLS core with PE and P routers exchanging labels between a customer's sites
Illustration: The House of Routing

I'm Jesús Espinoza, an instructor and Cisco Community Ambassador. In March 2021 I recorded the MPLS Masterclass live: two marathons with Cisco routers, one on L3VPN and one on VPLS. This guide is its companion: it brings together the 30 Cisco IOS and IOS XE commands I used to build the core, the Layer 3 VPNs and the Layer 2 VPNs.

Each command shows the IOS mode where you type it (the prompt) and what it's for. The examples use the lab data: PE-1 (1.1.1.1), P1 (2.2.2.2), P2 (3.3.3.3) and PE-2 (4.4.4.4), with OSPF 1 in the core and iBGP AS 100 between the PEs.

Mode: PE-1# privileged EXEC · PE-1(config)# global configuration · PE-1(config-if)# interface · PE-1(config-router)# router (OSPF or BGP) · PE-1(config-router-af)# BGP address family · PE-1(config-vrf)# VRF · PE-1(config-vrf-af)# VRF address family · PE-1(config-pw-class)# pseudowire class · PE-1(config-vfi)# VPLS VFI · PE-1(config-if-srv)# service instance · PE-1(config-bdomain)# bridge domain.

Download the PDF guide. The same guide, ready to print or keep handy while you build the lab.

Download the PDF guide

MPLS and LDP in the core

Control plane first: CEF, a label range of your own and LDP on the core interfaces. In the lab, OSPF 1 area 0 already advertises the loopbacks of all 4 routers.

#CommandWhat it's for
1PE-1(config)#ip cefEnables CEF, the forwarding plane MPLS builds the LFIB on.
2PE-1(config)#mpls label range 100 199Sets the router's label range (PE-1 uses 100-199) so you can spot its labels at a glance; it may need a reload.
3PE-1(config)#mpls label protocol ldpSets LDP as the label distribution protocol; it's the default in current releases.
4PE-1(config)#mpls ldp router-id Loopback0 forcePins the LDP router ID to Loopback0; with force the change is immediate and resets the LDP sessions.
5PE-1(config-if)#mpls ipEnables MPLS and LDP on the interface toward the core, never on the one facing the CE.
6P1(config-router)#mpls ldp autoconfig area 0Enables LDP on every OSPF interface in area 0 without configuring them one by one.
PE-1(config)# ip cef
PE-1(config)# mpls label range 100 199
PE-1(config)# mpls label protocol ldp
PE-1(config)# mpls ldp router-id Loopback0 force
PE-1(config)# interface GigabitEthernet0/2
PE-1(config-if)# mpls ip
! P1: label range 200-299 and LDP from the OSPF process
P1(config)# mpls label range 200 299
P1(config)# router ospf 1
P1(config-router)# mpls ldp autoconfig area 0

Verifying LDP and labels

Before you think about VPNs, check that LDP formed neighbors and that there are labels toward the remote loopbacks. If this layer fails, nothing that follows will work.

#CommandWhat it's for
7PE-1#show mpls interfacesLists the interfaces running MPLS and shows whether LDP came from the interface or from the IGP.
8PE-1#show mpls ldp discovery
show mpls ldp neighbor
Checks that LDP hellos are being sent and shows the sessions established with each neighbor.
9PE-1#show mpls ldp bindings
show mpls ldp bindings 4.4.4.4 32
Shows the LIB: the local label and the labels each neighbor advertised for every prefix.
10PE-1#show mpls forwarding-table
show ip cef 4.4.4.4 detail
Shows the LFIB (local label, outgoing label or Pop Label) and the label CEF imposes toward the remote PE.
PE-1# show mpls interfaces
PE-1# show mpls ldp discovery
PE-1# show mpls ldp neighbor
! Expect P1 as LDP peer: 2.2.2.2:0
PE-1# show mpls ldp bindings 4.4.4.4 32
PE-1# show mpls forwarding-table
! Local labels 100-199 (PE-1), outgoing labels 200-299 (P1)
PE-1# show ip cef 4.4.4.4 detail

VRF and MP-BGP VPNv4

An L3VPN isolates the customer in a VRF and carries its routes between PEs with MP-BGP. PE-1 uses VRF TU-CA1 with rd 300:300 and PE-2 uses TU-CA2 with rd 400:400; both use route target 3:3.

#CommandWhat it's for
11PE-1(config-vrf)#vrf definition TU-CA1
rd 300:300
Creates the customer VRF and assigns the route distinguisher that makes each prefix unique (the classic form is ip vrf).
12PE-1(config-vrf-af)#address-family ipv4
route-target both 3:3
Enables IPv4 in the VRF and imports and exports route target 3:3, the key that joins the customer's sites.
13PE-1(config-if)#vrf forwarding TU-CA1
ip address 192.168.1.1 255.255.255.0
Puts the interface toward the CE into the VRF; it removes the IP address, so you set it again (classic form: ip vrf forwarding).
14PE-1(config-router)#router bgp 100
neighbor 4.4.4.4 remote-as 100
neighbor 4.4.4.4 update-source Loopback0
Brings up iBGP between the PEs in AS 100, sourcing the session from the loopbacks.
15PE-1(config-router-af)#address-family vpnv4
neighbor 4.4.4.4 activate
neighbor 4.4.4.4 send-community both
Activates the VPNv4 family with the other PE and sends it the extended communities that carry the route target.
16PE-1(config-router-af)#address-family ipv4 vrf TU-CA1
redistribute ospf 20
Brings the routes the PE learns from the CE over OSPF 20 into MP-BGP.
17PE-1(config-router)#router ospf 20 vrf TU-CA1
redistribute bgp 100 subnets
Sends the other site's routes, learned through BGP, back to the CE over OSPF 20.
PE-1(config)# vrf definition TU-CA1
PE-1(config-vrf)# rd 300:300
PE-1(config-vrf)# address-family ipv4
PE-1(config-vrf-af)# route-target both 3:3
PE-1(config-vrf-af)# exit-address-family
PE-1(config-vrf)# router bgp 100
PE-1(config-router)# address-family vpnv4
PE-1(config-router-af)# neighbor 4.4.4.4 activate
PE-1(config-router-af)# neighbor 4.4.4.4 send-community both
PE-1(config-router-af)# exit-address-family
PE-1(config-router)# address-family ipv4 vrf TU-CA1
PE-1(config-router-af)# redistribute ospf 20

Verifying the L3VPN

Verify from the bottom up: the VRF, its routing table, the VPNv4 session and finally the traffic. Every command inside the VPN needs the VRF name.

#CommandWhat it's for
18PE-1#show vrf
show ip vrf
Lists the VRFs with their route distinguisher and interfaces (show ip vrf for the classic form).
19PE-1#show ip route vrf TU-CA1Shows the VRF routing table: the local CE routes from OSPF and the remote site routes from BGP.
20PE-1#show bgp vpnv4 unicast all summaryShows the VPNv4 sessions and how many prefixes the PE receives from each neighbor.
21PE-1#show bgp vpnv4 unicast vrf TU-CA1
show bgp vpnv4 unicast vrf TU-CA1 40.40.40.40
Shows the VRF's VPNv4 prefixes with their next hop, label and route target.
22PE-1#ping vrf TU-CA1 30.30.30.30
traceroute vrf TU-CA1 40.40.40.40
Tests connectivity inside the VRF; without vrf, the PE looks in the global table and fails.
PE-1# show vrf
PE-1# show ip route vrf TU-CA1
PE-1# show bgp vpnv4 unicast all summary
! Expect 4.4.4.4 with prefixes received
PE-1# show bgp vpnv4 unicast vrf TU-CA1 40.40.40.40
PE-1# ping vrf TU-CA1 30.30.30.30
PE-1# traceroute vrf TU-CA1 40.40.40.40
! The VRF name is case sensitive: tu-ca1 is not TU-CA1

L2VPN: pseudowire (VPWS) and VPLS

With AToM, a pseudowire joins two ports as if they were a cable; with VPLS, the core works like a multipoint switch. For VPLS I use the IOS XE l2vpn syntax; the classic form is l2 vfi … manual with neighbor.

#CommandWhat it's for
23PE-1(config-if)#xconnect 4.4.4.4 100 encapsulation mplsCreates the pseudowire toward the remote PE's loopback; VC ID 100 must match on both ends.
24PE-1(config-pw-class)#pseudowire-class PW-MPLS
encapsulation mpls
Defines a pseudowire template that you then apply with xconnect 4.4.4.4 100 pw-class PW-MPLS.
25PE-1(config-vfi)#l2vpn vfi context customerA
vpn id 159
member 4.4.4.4 encapsulation mpls
Creates the VPLS VFI with its VPN ID and one member per remote PE to build the full mesh.
26PE-1(config-if-srv)#service instance 555 ethernet
encapsulation default
Creates the service instance on the customer port; with encapsulation default it accepts every frame.
27PE-1(config-bdomain)#bridge-domain 2222
member GigabitEthernet1 service-instance 555
member vfi customerA
Joins the customer's service instance and the VFI in the same bridge domain.
! VPWS: same VC ID 100 on both PEs (PE-2 points to 1.1.1.1)
PE-1(config)# interface GigabitEthernet2
PE-1(config-if)# xconnect 4.4.4.4 100 encapsulation mpls
PE-1(config)# l2vpn vfi context customerA
PE-1(config-vfi)# vpn id 159
PE-1(config-vfi)# member 4.4.4.4 encapsulation mpls
PE-1(config)# interface GigabitEthernet1
PE-1(config-if)# service instance 555 ethernet
PE-1(config-if-srv)# encapsulation default
PE-1(config)# bridge-domain 2222
PE-1(config-bdomain)# member GigabitEthernet1 service-instance 555
PE-1(config-bdomain)# member vfi customerA

Verifying L2VPN

A pseudowire comes up when both PEs exchange the VC label over a targeted LDP session. These commands tell you where it got stuck.

#CommandWhat it's for
28PE-1#show mpls l2transport vc detail
show mpls l2transport vc 100
Shows each virtual circuit with its VC ID, remote PE, status and local and remote labels.
29PE-1#show mpls l2transport bindingShows the VC labels each PE advertised and received over the LDP session with the remote PE.
30PE-1#show l2vpn vfiShows each VPLS VFI with its VPN ID and the status of the pseudowires toward its neighbors.
PE-1# show mpls l2transport vc 100
PE-1# show mpls l2transport vc detail
! Expect VC ID 100 to 4.4.4.4 in state UP
PE-1# show mpls l2transport binding
PE-1# show l2vpn vfi
! Expect VFI customerA, VPN ID 159, neighbor 4.4.4.4
CE-B1# ping 20.20.20.20 source 10.10.10.10

What you take away

  • No LDP, no VPN: check neighbors, bindings and the LFIB first.
  • Pin the label range and the LDP router ID to Loopback0: troubleshooting becomes readable.
  • The route distinguisher makes a prefix unique; the route target decides who imports it.
  • Without send-community the route target never travels, and without redistribution both ways the CE learns nothing.
  • At Layer 2: the same VC ID on both ends for VPWS, and one member per remote PE for VPLS.

Build the Masterclass topology in GNS3 or CML and configure each section without looking at the guide.

Learn MPLS with the Masterclass

The House of Routing's MPLS Masterclass turns the two marathons I recorded live, L3VPN and VPLS, into free readings. The first reading is open to everyone, and the rest unlock with your free registration. Each chapter includes its YouTube videos with subtitles in Spanish, English, French and Portuguese.

See the Masterclass

Sources

Illustration: The House of Routing. Text by Jesús Espinoza, prepared with AI assistance and reviewed by him.

↑ Start of the article