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.
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.
| # | Command | What it's for |
|---|---|---|
| 1 | PE-1(config)#ip cef | Enables CEF, the forwarding plane MPLS builds the LFIB on. |
| 2 | PE-1(config)#mpls label range 100 199 | Sets the router's label range (PE-1 uses 100-199) so you can spot its labels at a glance; it may need a reload. |
| 3 | PE-1(config)#mpls label protocol ldp | Sets LDP as the label distribution protocol; it's the default in current releases. |
| 4 | PE-1(config)#mpls ldp router-id Loopback0 force | Pins the LDP router ID to Loopback0; with force the change is immediate and resets the LDP sessions. |
| 5 | PE-1(config-if)#mpls ip | Enables MPLS and LDP on the interface toward the core, never on the one facing the CE. |
| 6 | P1(config-router)#mpls ldp autoconfig area 0 | Enables 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.
| # | Command | What it's for |
|---|---|---|
| 7 | PE-1#show mpls interfaces | Lists the interfaces running MPLS and shows whether LDP came from the interface or from the IGP. |
| 8 | PE-1#show mpls ldp discoveryshow mpls ldp neighbor | Checks that LDP hellos are being sent and shows the sessions established with each neighbor. |
| 9 | PE-1#show mpls ldp bindingsshow mpls ldp bindings 4.4.4.4 32 | Shows the LIB: the local label and the labels each neighbor advertised for every prefix. |
| 10 | PE-1#show mpls forwarding-tableshow 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.
| # | Command | What it's for |
|---|---|---|
| 11 | PE-1(config-vrf)#vrf definition TU-CA1rd 300:300 | Creates the customer VRF and assigns the route distinguisher that makes each prefix unique (the classic form is ip vrf). |
| 12 | PE-1(config-vrf-af)#address-family ipv4route-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. |
| 13 | PE-1(config-if)#vrf forwarding TU-CA1ip 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). |
| 14 | PE-1(config-router)#router bgp 100neighbor 4.4.4.4 remote-as 100neighbor 4.4.4.4 update-source Loopback0 | Brings up iBGP between the PEs in AS 100, sourcing the session from the loopbacks. |
| 15 | PE-1(config-router-af)#address-family vpnv4neighbor 4.4.4.4 activateneighbor 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. |
| 16 | PE-1(config-router-af)#address-family ipv4 vrf TU-CA1redistribute ospf 20 | Brings the routes the PE learns from the CE over OSPF 20 into MP-BGP. |
| 17 | PE-1(config-router)#router ospf 20 vrf TU-CA1redistribute 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.
| # | Command | What it's for |
|---|---|---|
| 18 | PE-1#show vrfshow ip vrf | Lists the VRFs with their route distinguisher and interfaces (show ip vrf for the classic form). |
| 19 | PE-1#show ip route vrf TU-CA1 | Shows the VRF routing table: the local CE routes from OSPF and the remote site routes from BGP. |
| 20 | PE-1#show bgp vpnv4 unicast all summary | Shows the VPNv4 sessions and how many prefixes the PE receives from each neighbor. |
| 21 | PE-1#show bgp vpnv4 unicast vrf TU-CA1show bgp vpnv4 unicast vrf TU-CA1 40.40.40.40 | Shows the VRF's VPNv4 prefixes with their next hop, label and route target. |
| 22 | PE-1#ping vrf TU-CA1 30.30.30.30traceroute 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.
| # | Command | What it's for |
|---|---|---|
| 23 | PE-1(config-if)#xconnect 4.4.4.4 100 encapsulation mpls | Creates the pseudowire toward the remote PE's loopback; VC ID 100 must match on both ends. |
| 24 | PE-1(config-pw-class)#pseudowire-class PW-MPLSencapsulation mpls | Defines a pseudowire template that you then apply with xconnect 4.4.4.4 100 pw-class PW-MPLS. |
| 25 | PE-1(config-vfi)#l2vpn vfi context customerAvpn id 159member 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. |
| 26 | PE-1(config-if-srv)#service instance 555 ethernetencapsulation default | Creates the service instance on the customer port; with encapsulation default it accepts every frame. |
| 27 | PE-1(config-bdomain)#bridge-domain 2222member GigabitEthernet1 service-instance 555member 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.
| # | Command | What it's for |
|---|---|---|
| 28 | PE-1#show mpls l2transport vc detailshow mpls l2transport vc 100 | Shows each virtual circuit with its VC ID, remote PE, status and local and remote labels. |
| 29 | PE-1#show mpls l2transport binding | Shows the VC labels each PE advertised and received over the LDP session with the remote PE. |
| 30 | PE-1#show l2vpn vfi | Shows 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.
Sources
- Configure a Basic MPLS VPN Networkcisco.com
- MPLS LDP Autoconfiguration (MPLS: LDP Configuration Guide)cisco.com
- MPLS VPN VRF CLI for IPv4 and IPv6 VPNscisco.com
- Verify MPLS Layer 3 VPN Forwardingcisco.com
- Understand MPLS L2VPN Pseudowirecisco.com
- MPLS Configuration Guide, Cisco IOS XE 17.x: Configuring Virtual Private LAN Servicescisco.com
- Configuring VPLS between Cat9500 and ISR4Kcisco.com
- Troubleshoot Layer 2 VPN Virtual Private LAN Service on IOS XEcisco.com
Illustration: The House of Routing. Text by Jesús Espinoza, prepared with AI assistance and reviewed by him.
