MPLS Configuration Guide
The Multiprotocol Label Switching (MPLS) protocol is used on Internet Protocol (IP) backbone networks. MPLS uses connection-oriented label switching on connectionless IP networks. By combining Layer 3 routing technologies and Layer 2 switching technologies, MPLS leverages the flexibility of IP routing and the simplicity of Layer 2 switching.
MPLS is based on Internet Protocol version 4 (IPv4). The core MPLS technology can be extended to multiple network protocols, such as Internet Protocol version 6 (IPv6), Internet Packet Exchange (IPX), and Connectionless Network Protocol (CLNP). “Multiprotocol” in MPLS means that multiple network protocols are supported.
MPLS is used for tunneling but not a service or an application. MPLS supports multiple protocols and services. Moreover, it ensures security of data transmission.
MPLS Configuration
Section titled “MPLS Configuration”Static LSP
Section titled “Static LSP”| Operation | Command | Description |
|---|---|---|
| Configure IPv4 Route Forwarding with MPLS Labeling | ip route A.B.C.D/M|A.B.C.D gw label number | number: MPLS label ID to be marked, configuration range: 16 to 1048575 |
| Configure IPv6 Route Forwarding with MPLS Labeling | ipv6 route X:X::X:X/M gw label number | |
| Configure MPLS Static Label Processing Policy | mpls lsp number {A.B.C.D|X:X::X:X} {number|explicit-null|implicit-null} | explicit-null: The MPLS label in the neighbor notification message will be set to explicit-null (0). Upon receiving the message, the neighbor will automatically drop this MPLS label. implicit-null: Inform the neighbor that it is currently the second-to-last hop in the MPLS path and pop the MPLS label here. |
Dynamic LDP
Section titled “Dynamic LDP”| Operation | Command | Description |
|---|---|---|
| Enter MPLS LDP view | mpls ldp | |
| Configure the router-id of MPLS LDP | router-id ip-address | ip-address: Name the router-id in the format of an ipv4 address |
| Enter ipv4/ipv6 address-family | address-family ipv4|ipv6 | |
| Configure the IPv4/IPv6 addresses advertised by the LDP address family | discovery transport-address ip-address | |
| Establish a neighbor relationship with a remote LDP neighbor | neighbor ip-address targeted |
| Operation | Command | Description |
|---|---|---|
| Configure static PW | pseudowire static name | |
| Configure the local and remote labels for static pseudowires | mpls label local number remote number | number: Value range: 16–1048575 |
| Enter ipv4/ipv6 address-family | address-family ipv4|ipv6 | |
| Configure the static remote neighbor address for the static PW | neighbor {A.B.C.D|X:X::X:X} | |
| Configure dynamic PW | pseudowire name | |
| Configure the dynamic PW’s pw-id | pw-id ID | The PW-ID configured on PE devices connected to adjacent ends must be consistent for the PW state to be up. |
| Configure dynamic PW lsr-id | neighbor lsr-id A.B.C.D | |
| Configure different L2VPN types—VPLS and VPWS—based on specific usage scenarios | L2vpn name type {vpls|vpws} | vpls: Virtual Private LAN Service (VPLS) is a point-to-multipoint Layer 2 Virtual Private Network (L2VPN). Vpws: Virtual Private Network service is a point-to-point L2VPN. |
| Add PW members to the existing L2VPN | member pseudowire name | |
| Add an AC interface to the existing L2VPN | member interface {ethernet|vlan|link-aggregation} | VPLS only supports VLAN interfaces, while VPWS only supports physical interfaces and LAG interfaces. |
| Operation | Command | Description |
|---|---|---|
| Enter bgp configuration view | router bgp id | |
| Enter ipv4/ipv6 MPLS VPN view | address-family {ipv4|ipv6} vpn | |
| Activate the MPLS VPN neighbor | neighbor {A.B.C.D|X:X::X:X} activate | |
| Enter ipv4/ipv6 address-family | address-family {ipv4|ipv6} unicast | |
| Configure MPLS VPN Label Assignment Method | label vpn export {auto|allocation-mode {per-vrf|per-nexthop}|Label-number} | auto: Automatically assign MPLS labels to routes. allocation-mode per-vrf: Routes are assigned labels based on the VRF; routes within the same VRF are assigned the same label. allocation-mode per-nexthop: Assign labels based on the next hop of the route; routes with the same next hop are assigned the same label. Label-number: Manually set the MPLS label assigned to the route |
| Configuring RD Parameters for an MPLS VPN | rd vpn export {as-number:number|ip-address:number} | RD parameters are designed to resolve conflicts where internal networks at both ends of a VPN share the same route segment. RD is combined with the VPN prefix (VPNv4 address) to form a unique VPNv4 address. This combination of RD and VPN prefix creates a new routing entry, enabling each VPN route to be uniquely identified. |
| Configuring the RT Parameters for an MPLS VPN | rt vpn {import|export|both} {A.B.C.D:MN|EF:OPQR|GHJK:MN} | import: Configure RT parameters for receiving VPN routes export: Configure RT parameters for sending VPN routes RT parameters control the identifiers used for exporting and importing VPN routes, ensuring that VPN routes are correctly sent and received between different VPNs. |
| Export/Import VPN Routes | {export|import} vpn |
Display and Maintenance
Section titled “Display and Maintenance”| Operation | Command |
|---|---|
| View MPLS label information | show mpls table |
| View MPLS LDP neighbor relationships | show mpls ldp neighbor [detail] |
| View MPLS LDP label information | show mpls ldp binding |
| View MPLS L2VPN information | show mpls l2vpn |
| View MPLS PW information | show mpls pseudowires [detail] |
| View the routing and MPLS label information for all VRFs currently configured on the device | show {ipv4|ipv6} route vrf all |
Example of Reflect-acl Configuration
Section titled “Example of Reflect-acl Configuration”Network Requirements
The network topology is simple and stable, and the three router devices are MPLS backbone network devices. It is required to create a stable public network tunnel on the backbone network to carry MPLS tunnel services.

Procedure
Dveice 1
sonic(config)# interface ethernet 7sonic(config-if-7)# ip address 80.0.0.1/24sonic(config)# interface ethernet 15sonic(config-if-15)# ip address 10.1.1.2/24sonic(config-if-15)# mpls enablesonic(config)# ip route 90.0.0.0/24 10.1.1.1 label 16Dveice 2
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.1.1.1/24sonic(config-if-1)# mpls enablesonic(config)# interface ethernet 3sonic(config-if-3)# ip address 20.1.1.1/24sonic(config-if-3)# mpls enablesonic(config)# mpls lsp 16 90.0.0.100 implicit-nullsonic(config)# mpls lsp 17 80.0.0.100 implicit-nullDveice 3
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 90.0.0.1/24sonic(config)# interface ethernet 3sonic(config-if-3)# ip address 20.1.1.2/24sonic(config-if-3)# mpls enablesonic(config)# ip route 80.0.0.0/24 20.1.1.1 label 17Example of MPLS L2VPN VPLS Configuration
Section titled “Example of MPLS L2VPN VPLS Configuration”Network Requirements
Device1, Device2, and Device3 are PE devices of the IP/MPLS backbone network. MPLS L2VPN services need to be deployed on Device1, Device2, and Device3 to interconnect VPN sites. Therefore, local LDP sessions need to be configured between LSRs to establish LDP LSPs to carry VPN services.

Procedure
Device 1
sonic(config)#interface ethernet 7sonic(config-if-7)# switchport access vlan 100sonic(config)#interface ethernet 16sonic(config-if-16)# ip address 10.1.1.2/24sonic(config-if-16)# mpls ldpsonic(config-if-16)# ip ospf area 1sonic(config-if-16)# mpls enablesonic(config)#interface loopback 0sonic(config-loif-0)# ip address 1.1.1.1/32sonic(config)# vlan 100sonic(config)# l2vpn test type vplssonic(config-l2vpn)# member interface vlan 100sonic(config-l2vpn)# member pseudowire 219sonic(config-l2vpn)# member pseudowire 220sonic(config)#router ospfsonic(config-router)# redistribute connectedsonic(config)# mpls ldpsonic(config-ldp)# router-id 1.1.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 1.1.1.1sonic(config-ldp-af)# neighbor 3.3.3.3 targetedsonic(config-ldp-af)# neighbor 4.4.4.4 targetedsonic(config)# pseudowire 219sonic(config-pw)# neighbor lsr-id 3.3.3.3sonic(config-pw)# neighbor address 3.3.3.3sonic(config-pw)# pw-id 1sonic(config)# pseudowire 220sonic(config-pw)# neighbor lsr-id 4.4.4.4sonic(config-pw)# neighbor address 4.4.4.4sonic(config-pw)# pw-id 2Dveice 2
sonic(config)# interface ethernet 13sonic(config-if-13)# switchport access vlan 100sonic(config)# interface ethernet 16sonic(config-if-16)# ip address 20.1.1.2/24sonic(config-if-16)# mpls ldpsonic(config-if-16)# ip ospf area 1sonic(config-if-16)# mpls enablesonic(config)# interface loopback 0sonic(config-loif-0)# ip address 3.3.3.3/32sonic(config)# vlan 100sonic(config)# l2vpn test type vplssonic(config-l2vpn)# member interface vlan 100sonic(config-l2vpn)# member pseudowire 217sonic(config-l2vpn)# member pseudowire 220sonic(config)# router ospfsonic(config-router)# redistribute connectedsonic(config)# mpls ldpsonic(config-ldp)# router-id 3.3.3.3sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 3.3.3.3sonic(config-ldp-af)# neighbor 1.1.1.1 targetedsonic(config-ldp-af)# neighbor 4.4.4.4 targetedsonic(config)# pseudowire 217sonic(config-pw)# neighbor lsr-id 1.1.1.1sonic(config-pw)# neighbor address 1.1.1.1sonic(config-pw)# pw-id 1sonic(config)# pseudowire 220sonic(config-pw)# neighbor lsr-id 4.4.4.4sonic(config-pw)# neighbor address 4.4.4.4sonic(config-pw)# pw-id 3Dveice 3
sonic(config)# interface ethernet 3sonic(config-if-13)# switchport access vlan 100sonic(config)# interface ethernet 16sonic(config-if-16)# ip address 30.1.1.2/24sonic(config-if-16)# mpls ldpsonic(config-if-16)# ip ospf area 1sonic(config-if-16)# mpls enablesonic(config)# interface loopback 0sonic(config-loif-0)# ip address 4.4.4.4/32sonic(config)# vlan 100sonic(config)# l2vpn test type vplssonic(config-l2vpn)# member interface vlan 100sonic(config-l2vpn)# member pseudowire 217sonic(config-l2vpn)# member pseudowire 219sonic(config)# router ospfsonic(config-router)# redistribute connectedsonic(config)# mpls ldpsonic(config-ldp)# router-id 4.4.4.4sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 4.4.4.4sonic(config-ldp-af)# neighbor 1.1.1.1 targetedsonic(config-ldp-af)# neighbor 3.3.3.3 targetedsonic(config)# pseudowire 217sonic(config-pw)# neighbor lsr-id 1.1.1.1sonic(config-pw)# neighbor address 1.1.1.1sonic(config-pw)# pw-id 2sonic(config)# pseudowire 219sonic(config-pw)# neighbor lsr-id 3.3.3.3sonic(config-pw)# neighbor address 3.3.3.3sonic(config-pw)# pw-id 3Transer Device
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.1.1.1/24sonic(config-if-1)# mpls ldpsonic(config-if-1)# ip ospf area 1sonic(config-if-1)# mpls enablesonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.1.1.1/24sonic(config-if-2)# mpls ldpsonic(config-if-2)# ip ospf area 1sonic(config-if-2)# mpls enablesonic(config)# interface ethernet 3sonic(config-if-3)# ip address 30.1.1.1/24sonic(config-if-3)# mpls ldpsonic(config-if-3)# ip ospf area 1sonic(config-if-3)# mpls enablesonic(config)# interface loopback 0sonic(config-loif-0)# ip address 2.2.2.2/32sonic(config)# router ospfsonic(config-router)# redistribute connectedsonic(config)# mpls ldpsonic(config-ldp)# router-id 2.2.2.2sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 2.2.2.2Example of MPLS L2VPN VPLS Configuration
Section titled “Example of MPLS L2VPN VPLS Configuration”Network Requirements
PE1, PE2, and PE3 are PE devices of the IP/MPLS backbone network. MPLS L3VPN services need to be deployed on PE1, PE2, and PE3 to interconnect VPN sites. Therefore, local LDP sessions need to be configured between LSRs to establish LDP LSPs and carry VPN services.

| Device | Interface | IP Adderss |
|---|---|---|
| CE1 | Port1 | 80.0.0.100/24 |
| PE1 | Loopback0 | 1.1.1.1/32 |
| Port1 | 80.0.0.1/24 | |
| Port2 | 80.0.1.1/24 | |
| Port3 | 10.1.1.2/24 | |
| CE2 | Port1 | 80.0.1.100/24 |
| P | Loopback0 | 2.2.2.2/32 |
| Port1 | 10.1.1.1/24 | |
| Port2 | 20.1.1.1/24 | |
| CE3 | Port1 | 90.0.0.100/24 |
| PE2 | Loopback0 | 3.3.3.3/32 |
| Port1 | 90.0.0.1/24 | |
| Port2 | 90.0.1.1/24 | |
| Port3 | 20.1.1.1/24 | |
| CE4 | Port1 | 90.0.1.100/24 |
Device 1
sonic(config)# vrf l3vpnsonic(config)# vrf l3vpn1sonic(config)# interface ethernet 13sonic(config-if-13)# ip address 80.0.0.1/24sonic(config-if-13)# vrf l3vpnsonic(config)# interface ethernet 14sonic(config-if-14)# ip address 110.0.0.1/24sonic(config-if-14)# vrf l3vpn1sonic(config)# interface ethernet 16sonic(config-if-16)# ip address 10.1.1.2/24sonic(config-if-16)# mpls ldpsonic(config-if-16)# ip ospf area 1sonic(config-if-16)# mpls enablesonic(config)# interface loopback 0sonic(config-loif-0)# ip address 1.1.1.1/32sonic(config)# router bgp 1sonic(config-router)# bgp router-id 1.1.1.1sonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 3.3.3.3 remote-as 1sonic(config-router)# neighbor 3.3.3.3 update-source 1.1.1.1sonic(config-router)# address-family ipv4 vpnsonic(config-router-af)# neighbor 3.3.3.3 activatesonic(config)# router bgp 1 vrf l3vpnsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 80.0.0.100 remote-as 220sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# redistribute connectedsonic(config-router-af)# label vpn export autosonic(config-router-af)# rd vpn export 1.1.1.1:1sonic(config-router-af)# rt vpn import 3.3.3.3:2sonic(config-router-af)# rt vpn export 1.1.1.1:1sonic(config-router-af)# export vpnsonic(config-router-af)# import vpnsonic(config)# router bgp 1 vrf l3vpn1sonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 110.0.0.100 remote-as 221sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# redistribute connectdsonic(config-router-af)# label vpn export autosonic(config-router-af)# rd vpn export 110.0.0.1:3sonic(config-router-af)# rt vpn import 100.0.0.1:4sonic(config-router-af)# rt vpn export 110.0.0.1:3sonic(config-router-af)# export vpnsonic(config-router-af)# import vpnsonic(config)# router ospfsonic(config-router)# redistribute connectedsonic(config)# mpls ldpsonic(config-ldp)# router-id 1.1.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp)# discovery transport-address 1.1.1.1P
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.1.1.1/24sonic(config-if-1)# mpls ldpsonic(config-if-1)# ip ospf area 1sonic(config-if-1)# mpls enablesonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.1.1.1/24sonic(config-if-2)# mpls ldpsonic(config-if-2)# ip ospf area 1sonic(config-if-2)# mpls enablesonic(config)# interface loopback 0sonic(config-loif-0)# ip address 2.2.2.2/32sonic(config)#router ospfsonic(config-router)# redistribute connectedsonic(config)# mpls ldpsonic(config-ldp)# router-id 2.2.2.2sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 2.2.2.2PE2
sonic(config)# vrf l3vpnsonic(config)# vrf l3vpn1sonic(config)# interface ethernet 10sonic(config-if-10)# ip address 90.0.0.1/24sonic(config-if-10)# vrf l3vpnsonic(config)# interface ethernet 12sonic(config-if-12)# ip address 100.0.0.1/24sonic(config-if-12)# vrf l3vpn1sonic(config)# interface ethernet 16sonic(config-if-16)# ip address 20.1.1.2/24sonic(config-if-16)# mpls ldpsonic(config-if-16)# ip ospf area 1sonic(config-if-16)# mpls enablesonic(config)# interface loopback 0sonic(config-loif-0)# ip address 3.3.3.3/32sonic(config)# router bgp 1sonic(config-router)# bgp router-id 3.3.3.3sonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 1.1.1.1 remote-as 1sonic(config-router)# neighbor 1.1.1.1 update-source 3.3.3.3sonic(config-router)# address-family ipv4 vpnsonic(config-router-af)# neighbor 1.1.1.1 activatesonic(config)# router bgp 1 vrf l3vpnsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 90.0.0.100 remote-as 101sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# redistribute connectedsonic(config-router-af)# label vpn export autosonic(config-router-af)# rd vpn export 3.3.3.3:2sonic(config-router-af)# rt vpn import 1.1.1.1:1sonic(config-router-af)# rt vpn export 3.3.3.3:2sonic(config-router-af)# export vpnsonic(config-router-af)# import vpnsonic(config)# router bgp 1 vrf l3vpn1sonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 100.0.0.100 remote-as 100sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# redistribute connectedsonic(config-router-af)# label vpn export autosonic(config-router-af)# rd vpn export 100.0.0.1:4sonic(config-router-af)# rt vpn import 110.0.0.1:3sonic(config-router-af)# rt vpn export 100.0.0.1:4sonic(config-router-af)# export vpnsonic(config-router-af)# import vpnsonic(config)# router ospfsonic(config-router)# redistribute connectedsonic(config)# mpls ldpsonic(config-ldp)# router-id 3.3.3.3sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 3.3.3.3CE1
sonic(config)# interface ethernet 11sonic(config-if-11)# ip address 80.0.0.100/24sonic(config)# router bgp 220sonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 80.0.0.1 remote-as 1sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# redistribute connectedCE2
sonic(config)# interface ethernet 13sonic(config-if-13)# ip address 90.0.0.100/24sonic(config)# router bgp 101sonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 90.0.0.1 remote-as 1sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# redistribute connectedCE3
sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 110.0.0.100/24sonic(config)# router bgp 221sonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 110.0.0.1 remote-as 1sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# redistribute connectedCE4
sonic(config)# interface ethernet 12sonic(config-if-12)# ip address 100.0.0.100/24sonic(config)# router bgp 100sonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 100.0.0.1 remote-as 1sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# redistribute connected