MPLS Configuration
MPLS (Multiprotocol Label Switching) is an IP (Internet Protocol) backbone network technology. MPLS introduces the concept of connection oriented label switching on connectionless IP networks, combining layer 3 routing technology with layer 2 switching technology, fully leveraging the flexibility of IP routing and the simplicity of layer 2 switching. Not only does it support multiple high-level protocols and services, but it can also ensure the security of information transmission to a certain extent.
Configuration Example
Section titled “Configuration Example”Example of MPLS Static LSP Configuration
Section titled “Example of MPLS Static LSP Configuration”Networking Requirements
In this network, only MPLS’s static LSP is used, allowing CE1 and CE2 to communicate with each other. Therefore, it is necessary to configure LSP1 from PE1 to PE2, and P2 to display empty tags using PHP; Configure LSP2 from PE2 to PE1, P1 using PHP implicit null tags.

Configuration Steps
1. Device PE1 configuration
# Configure IP address for interface
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 12.12.12.1/24sonic(config)# interface ethernet 3sonic(config-if-3)# ip address 10.1.1.254/24# Configure LSP1: Route labeled 50 to 20.1.1.0/24
sonic(config)# ip route 20.1.1.0/24 12.12.12.2 label 502. Device P1 configuration
# Configure IP addresses for Ethernet1 and Ethernet2 respectively
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 12.12.12.2/24sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 14.14.14.1/24# Configure LSP1: Route with inbound label of 50 and outbound label of 60
sonic(config)# mpls lsp 50 14.14.14.2 60# Configure LSP2: Enter the route with label 80 and strip off the label
sonic(config)# mpls lsp 80 12.12.12.1 implicit-null3. Device P2 configuration
# Configure IP addresses for Ethernet1 and Ethernet2 respectively
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 16.16.16.1/24sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 14.14.14.2/24# Configure LSP1: Route with inbound label of 60 and outbound label of 0
sonic(config)# mpls lsp 60 16.16.16.2 explicit-null# Configure LSP2: Route with inbound label of 70 and outbound label of 80
sonic(config)# mpls lsp 70 14.14.14.1 804. Device PE2 configuration
# Configure IP addresses for Ethernet1 and Ethernet3 respectively
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 16.16.16.2/24sonic(config)# interface ethernet 3sonic(config-if-3)# ip address 20.1.1.254/24# Configure LSP1: Route labeled 70 to 10.1.1.0/24
sonic(config)# ip route 10.1.1.0/24 16.16.16.1 label 705. Device CE1 configuration interface IP address and routing
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.1.1.1/24sonic(config)# ip route 20.1.1.0/24 10.1.1.2546. Equipment CE2 configuration interface IP address and routing
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 20.1.1.1/24sonic(config)# ip route 10.1.1.0/24 20.1.1.2541. View the route on PE1 with the purpose of the 20.1.1.1/24 network segment and label it as 50.
2. When viewing the MPLS table on P1, it can be seen that when in_1abel is 50, it needs to be modified to label 60; When the inlabel is 80, the label needs to be peeled off.
3. When viewing the MPLS table on P1, it can be seen that when in1abel is 60, it needs to be modified to label 0; When in1abel is 70, it needs to be modified to label 80.
4. Check the route on PE2 for the 10.1.1.1/24 network segment and label it as 70.
5. CE1 and CE2 can communicate with each other.
Example of MPLS L3VPN Configuration
Section titled “Example of MPLS L3VPN Configuration”Networking Requirements
In this network, OSPF and LDP protocols run between the backbone networks PE1-P-PE2; Run MP-BGP protocol on PE1 and PE2 to transmit VPN routes; Afterwards, the EBGP protocol is run between PE1 and CE1, PE2 and CE2 respectively, ultimately achieving mutual communication between the same VPN CE1 and CE2.

Configuration Steps
1. Device PE1 Configuration
# Configure the IP address for the interface, create VRF1, and add the Ethernet1 interface
sonic(config)# vrf 1sonic(config)# interface ethernet 1sonic(config-if-1)# vrf 1sonic(config-if-1)# ip address 10.1.1.2/24sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.1.1.1/24# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 1.1.1.1/32sonic(config)# router ospfsonic(config-router)# ospf router-id 1.1.1.1sonic(config-router)# redistribute connectedsonic(config-router)# network 20.1.1.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 1.1.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 20.1.1.1sonic(config-ldp-af)# interface ethernet 2# Create MP-BGP and establish neighbors with PE2
sonic(config)# router bgp 200sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 3.3.3.3 remote-as 200sonic(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 activate# Create EBGP and establish neighbors with CE1
sonic(config)# router bgp 200 vrf 1sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 10.1.1.1 remote-as 100sonic(config-router)# address-family ipv4 unicastsonic(config-router)# neighbor 10.1.1.1 activatesonic(config-router-af)# label vpn export autosonic(config-router-af)# rd vpn export 1.1.1.1:2sonic(config-router-af)# rt vpn both 200:2sonic(config-router-af)# export vpnsonic(config-router-af)# import vpn2. Device P Configuration
# Interface configuration IP address
sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.1.1.2/24sonic(config)# interface ethernet 3sonic(config-if-3)# ip address 30.1.1.2/24# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 2.2.2.2/32sonic(config)# router ospfsonic(config-router)# ospf router-id 2.2.2.2sonic(config-router)# redistribute connectedsonic(config-router)# network 20.1.1.0/24 area 1sonic(config-router)# network 30.1.1.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 2.2.2.2sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 20.1.1.2sonic(config-ldp-af)# interface ethernet 2sonic(config-ldp-af-if)# exitsonic(config-ldp-af)# interface ethernet 33. Device PE2 Configuration
# Configure the IP address for the interface, create VRF1, and add the interface to it
sonic(config)# vrf 1sonic(config)# interface ethernet 1sonic(config-if-1)# vrf 1sonic(config-if-1)# ip address 10.2.2.2/24sonic(config)# interface ethernet 3sonic(config-if-3)# ip address 30.1.1.1/24# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 3.3.3.3/32sonic(config)# router ospfsonic(config-router)# ospf router-id 3.3.3.3sonic(config-router)# redistribute connectedsonic(config-router)# network 30.1.1.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 3.3.3.3sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 30.1.1.1sonic(config-ldp-af)# interface ethernet 3# Create MP-BGP and establish neighbors with PE1
sonic(config)# router bgp 200sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 1.1.1.1 remote-as 200sonic(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 activate# Create EBGP and establish neighbors with CE2
sonic(config)# router bgp 200 vrf 1sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 10.2.2.1 remote-as 300sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 10.2.2.1 activatesonic(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 both 200:2sonic(config-router-af)# export vpnsonic(config-router-af)# import vpn4. Device CE1 Configuration
# Interface IP address configuration
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.1.1.1/24# Create EBGP, establish neighbors with PE1, and introduce direct routing
sonic(config)# router bgp 100sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 10.1.1.2 remote-as 200sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 10.1.1.2 activatesonic(config-router-af)# redistribute connected5. Device CE2 Configuration
# Interface IP address configuration
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.2.2.1/24# Create EBGP, establish neighbors with PE2, and introduce direct routing
sonic(config)# router bgp 300sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 10.2.2.2 remote-as 200sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 10.2.2.2 activatesonic(config-router-af)# redistribute connected1. PE1 and PE2 establish an MP-BGP neighbor relationship, exchange VPN routes, and CE1 and CE2 routes are reachable.
2. CE1 and CE2 can communicate with each other.
Example of MPLS L2VPN VPLS Configuration
Section titled “Example of MPLS L2VPN VPLS Configuration”Networking Requirements
In this network, PE1, P, PE2, and PE3 all run OSPF and LDP protocols. Then, VPLS type L2VPNs are configured in PE1, PE2, and PE3 respectively, and LDP is used to generate labels, ultimately achieving mutual communication among the same layer 2 VPN PC1, PC2, and PC3.

Configuration Steps
1. Device PE1 Configuration
# Interface IP address configuration
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 12.12.12.1/24#Create VLAN as the AC interface for L2VPN and add the interface to VLAN
sonic(config)# interface ethernet 3sonic(config-if-3)# switchport access vlan 100#Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 100.1.1.1/32sonic(config)# router ospfsonic(config-router)# ospf router-id 100.1.1.1sonic(config-router)# redistribute connectedsonic(config-router)# redistribute staticsonic(config-router)# network 12.12.12.0/24 area 1#Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 100.1.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 100.1.1.1sonic(config-ldp-af)# exit-address-family#Create PW
sonic(config)# pseudowire pw12sonic(config-pw)# neighbor lsr-id 100.3.1.1sonic(config-pw)# pw-id 300sonic(config)# pseudowire pw13sonic(config-pw)# neighbor lsr-id 100.4.1.1sonic(config-pw)# pw-id 400# Create L2VPN and configure PW and AC
sonic(config)# l2vpn A type vplssonic(config-l2vpn)# member interface vlan 100sonic(config-l2vpn)# member pseudowire pw12sonic(config-l2vpn)# member pseudowire pw132. Device P Configuration
# Interface IP address configuration
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 12.12.12.2/24sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 14.14.14.2/24sonic(config)# interface ethernet 3sonic(config-if-3)# ip address 16.16.16.2/24# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 100.2.1.1/32sonic(config)# router ospfsonic(config-router)# ospf router-id 100.2.1.1sonic(config-router)# redistribute connectedsonic(config-router)# redistribute staticsonic(config-router)# network 12.12.12.0/24 area 1sonic(config-router)# network 14.14.14.0/24 area 1sonic(config-router)# network 16.16.16.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 100.2.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 100.2.1.1sonic(config-ldp-af)# exit-address-family3. Device PE2 Configuration
# Create VLAN as the AC interface for L2VPN and add the interface to VLAN
sonic(config)# vlan 100sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 14.14.14.1/24sonic(config)# interface ethernet 3sonic(config-if-3)# switchport access vlan 100# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 100.3.1.1/32sonic(config)# router ospfsonic(config-router)# ospf router-id 100.3.1.1sonic(config-router)# redistribute connectedsonic(config-router)# redistribute staticsonic(config-router)# network 14.14.14.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 100.3.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 100.3.1.1sonic(config-ldp-af)# exit-address-family# Create PW
sonic(config)# pseudowire pw12sonic(config-pw)# neighbor lsr-id 100.1.1.1sonic(config-pw)# pw-id 300sonic(config)# pseudowire pw23sonic(config-pw)# neighbor lsr-id 100.4.1.1sonic(config-pw)# pw-id 500# Create L2VPN and configure PW and AC
sonic(config)# l2vpn A type vplssonic(config-l2vpn)# member interface vlan 100sonic(config-l2vpn)# member pseudowire pw12sonic(config-l2vpn)# member pseudowire pw234. Device PE3 Configuration
#Create VLAN as the AC interface for L2VPN and add the interface to VLAN
sonic(config)# vlan 100sonic(config)# interface ethernet 3sonic(config-if-3)# ip address 16.16.16.1/24sonic(config)# interface ethernet 1sonic(config-if-1)# switchport access vlan 100# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 100.4.1.1/32sonic(config)# router ospfsonic(config-router)# ospf router-id 100.4.1.1sonic(config-router)# redistribute connectedsonic(config-router)# redistribute staticsonic(config-router)# network 16.16.16.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 100.4.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 100.4.1.1sonic(config-ldp-af)# exit-address-family# Create PW
sonic(config)# pseudowire pw13sonic(config-pw)# neighbor lsr-id 100.1.1.1sonic(config-pw)# pw-id 400sonic(config)# pseudowire pw23sonic(config-pw)# neighbor lsr-id 100.3.1.1sonic(config-pw)# pw-id 500# Create L2VPN and configure PW and AC
sonic(config)# l2vpn A type vplssonic(config-pw)# member interface vlan 100sonic(config-pw)# member pseudowire pw13sonic(config-pw)# member pseudowire pw23Verification
1. Device P establishes LDP neighbor relationships with PE1 and PE2 respectively.
2. Establish LDP neighbor relationship between devices PE1 and PE2.
3. PC1, PC2, and PC3 can communicate with each other.
Example of MPLS L2VPN VPWS Configuration
Section titled “Example of MPLS L2VPN VPWS Configuration”Networking Requirements
In this network, OSPF and LDP protocols are run between PE1, P, and PE2. VPWS type L2VPN is configured on PE1 and PE2, and LDP is used to generate labels, ultimately achieving communication between PC1 and PC2 of the same layer 2 VPN.

Configuration Steps
1. Device PE1 Configuration
#Interface IP address configuration
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 12.12.12.1/24# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 100.1.1.1/32sonic(config)# router ospfsonic(config-router)# ospf router-id 100.1.1.1sonic(config-router)# redistribute connectedsonic(config-router)# redistribute staticsonic(config-router)# network 12.12.12.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 100.1.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 100.1.1.1sonic(config-ldp-af)# interface ethernet 1# Create PW
sonic(config)# pseudowire pw1sonic(config-pw)# neighbor address 100.3.1.1sonic(config-pw)# neighbor lsr-id 100.3.1.1sonic(config-pw)# pw-id 100# Create a VPWS type L2VPN and configure PW and AC
sonic(config)# l2vpn A type vpwssonic(config-l2vpn)# member interface ethernet 3sonic(config-l2vpn)# member pseudowire pw12. Device P Configuration
# Interface IP address configuration
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 12.12.12.2/24sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 14.14.14.2/24# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-1)# ip address 100.2.1.1/32sonic(config)# router ospfsonic(config-router)# ospf router-id 100.2.1.1sonic(config-router)# redistribute connectedsonic(config-router)# redistribute staticsonic(config-router)# network 12.12.12.0/24 area 1sonic(config-router)# network 14.14.14.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 100.2.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 100.2.1.1sonic(config-ldp-af)# interface ethernet 1sonic(config-ldp-af-if)# exitsonic(config-ldp-af)# interface ethernet 23. Device PE2 Configuration
# Interface IP address configuration
sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 14.14.14.1/24# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 100.3.1.1/32sonic(config)# router ospfsonic(config-router)# ospf router-id 100.3.1.1sonic(config-router)# redistribute connectedsonic(config-router)# redistribute staticsonic(config-router)# network 14.14.14.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 100.3.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp)# discovery transport-address 100.3.1.1sonic(config-ldp-af)# interface ethernet 2# Create PW
sonic(config)# pseudowire pw1sonic(config-pw)# neighbor address 100.1.1.1sonic(config-pw)# neighbor lsr-id 100.1.1.1sonic(config-pw)# pw-id 100# Create a VPWS type L2VPN and configure PW and AC
sonic(config)# l2vpn A type vpwssonic(config-l2vpn)# member interface ethernet 3sonic(config-l2vpn)# member pseudowire pw1Verification
1. Device P establishes LDP neighbor relationships with PE1 and PE2 respectively.
2. Establish LDP neighbor relationship between devices PE1 and PE2.
3. PC1 and PC2 can communicate with each other.
Exampleof MPLS L3VPN OptionA Configuration
Section titled “Exampleof MPLS L3VPN OptionA Configuration”Networking Requirements
In this network, the interfaces interconnecting two ASBRs, as well as CE1 and CE2, belong to the same VPN; Run OSPF and LDP protocols between PE1, ASBR1 and PE2, ASBR2 respectively, and then establish EBGP neighbors between PE and CE, as well as between two ASBRs; Establish MP-IBGP neighbors between PE and ASBR, ultimately achieving mutual communication between CE1 and CE2.

Configuration Steps
1. Device PE1 Configuration
# Configure the IP address for the interface, create VRF1, and add the Ethernet1 interface
sonic(config)# vrf 1sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.1.1.1/24sonic(config-if-1)# vrf 1sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.1.1.1/24# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 1.1.1.1/32sonic(config)# router ospfsonic(config-router)# ospf router-id 1.1.1.1sonic(config-router)# redistribute connectedsonic(config-router)# network 20.1.1.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 1.1.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 20.1.1.1sonic(config-ldp-af)# interface ethernet 2# Create MP-BGP and establish neighbors with ASBR1
sonic(config)# router bgp 200sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 2.2.2.2 remote-as 200sonic(config-router)# neighbor 2.2.2.2 update-source 1.1.1.1sonic(config-router)# address-family ipv4 vpnsonic(config-router-af)# neighbor 2.2.2.2 activate# Create EBGP and establish neighbors with CE1
sonic(config)# router bgp 200 vrf 1sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 10.1.1.2 remote-as 101sonic(config-router)# neighbor 10.1.1.2 update-source 10.1.1.1sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 10.1.1.2 activatesonic(config-router-af)# redistribute connectedsonic(config-router-af)# label vpn export autosonic(config-router-af)# rd vpn export 200:1sonic(config-router-af)# rt vpn both 1:1sonic(config-router-af)# export vpnsonic(config-router-af)# import vpn2. Device ASBR1 Configuration
# Configure the IP address for the interface, create VRF1, and add the Ethernet3 interface
sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.1.1.2/24sonic(config)# interface ethernet 3sonic(config-if-3)# ip address 30.1.1.1/24sonic(config-if-3)# vrf 1# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 2.2.2.2/32sonic(config)# router ospfsonic(config-router)# ospf router-id 2.2.2.2sonic(config-router)# redistribute connectedsonic(config-router)# network 20.1.1.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 2.2.2.2sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 20.1.1.2sonic(config-ldp-af)# interface ethernet 2# Create MP-BGP and establish neighbors with PE1
sonic(config)# router bgp 200sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 1.1.1.1 remote-as 200sonic(config-router)# neighbor 1.1.1.1 update-source 2.2.2.2sonic(config-router)# address-family ipv4 vpnsonic(config-router-af)# neighbor 1.1.1.1 activate# Create EBGP and establish neighbors with ASBR2
sonic(config)# router bgp 200 vrf 1sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 30.1.1.2 remote-as 300sonic(config-router)# neighbor 30.1.1.2 ebgp-multihop 10sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 30.1.1.2 activatesonic(config-router-af)# redistribute connectedsonic(config-router-af)# label vpn export autosonic(config-router-af)# rd vpn export 200:2sonic(config-router-af)# rt vpn both 1:1sonic(config-router-af)# export vpnsonic(config-router-af)# import vpn3. Device ASBR2 Configuration
# Configure the IP address for the interface, create VRF1, and add the Ethernet3 interface
sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.2.2.2/24sonic(config)# interface ethernet 3sonic(config-if-3)# ip address 30.1.1.2/24sonic(config-if-3)# vrf 1# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 3.3.3.3/32sonic(config)# router ospfsonic(config-router)# ospf router-id 3.3.3.3sonic(config-router)# redistribute connectedsonic(config-router)# network 20.2.2.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 3.3.3.3sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 20.2.2.2sonic(config-ldp-af)# interface ethernet 2# Create MP-BGP and establish neighbors with PE2
sonic(config)# router bgp 300sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 4.4.4.4 remote-as 300sonic(config-router)# neighbor 4.4.4.4 update-source 3.3.3.3sonic(config-router)# address-family ipv4 vpnsonic(config-router-af)# neighbor 4.4.4.4 activate# Create EBGP and establish neighbors with ASBR1
sonic(config)# router bgp 300 vrf 1sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 30.1.1.1 remote-as 200sonic(config-router)# neighbor 30.1.1.1 ebgp-multihop 10sonic(config-router)# neighbor 30.1.1.1 update-source 30.1.1.2sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 30.1.1.1 activatesonic(config-router-af)# redistribute connectedsonic(config-router-af)# label vpn export autosonic(config-router-af)# rd vpn export 300:2sonic(config-router-af)# rt vpn both 3:3sonic(config-router-af)# export vpnsonic(config-router-af)# import vpn4. Device PE2 Configuration
# Configure the IP address for the interface, create VRF1, and add the Ethernet1 interface
sonic(config)# vrf 1sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.2.2.1/24sonic(config-if-1)# vrf 1sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.2.2.1/24# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 4.4.4.4/32sonic(config)# router ospfsonic(config-router)# ospf router-id 4.4.4.4sonic(config-router)# redistribute connectedsonic(config-router)# network 20.2.2.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 4.4.4.4sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 20.2.2.1sonic(config-ldp-af)# interface ethernet 2# Create EBGP and establish neighbors with ASBR2
sonic(config)# router bgp 300sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 3.3.3.3 remote-as 300sonic(config-router)# neighbor 3.3.3.3 update-source 4.4.4.4sonic(config-router)# address-family ipv4 vpnsonic(config-router-af)# neighbor 3.3.3.3 activate# Create EBGP and establish neighbors with CE2
sonic(config)# router bgp 300 vrf 1sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 10.2.2.2 remote-as 102sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 10.2.2.2 activatesonic(config-router-af)# redistribute connectedsonic(config-router-af)# label vpn export autosonic(config-router-af)# rd vpn export 300:1sonic(config-router-af)# rt vpn both 3:3sonic(config-router-af)# export vpnsonic(config-router-af)# import vpn5. CE1 Configuration
# Configure interface Ethernet1 IP address
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.1.1.2/24# Create EBGP, establish neighbors with PE1, and introduce direct routing
sonic(config)# router bgp 101sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 10.1.1.1 remote-as 200sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 10.1.1.1 activatesonic(config-router-af)# redistribute connected6. CE2 Configuration
# Configure interface Ethernet1 IP address
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.2.2.2/24# Create EBGP, establish neighbors with PE2, and introduce direct routing
sonic(config)# router bgp 102sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 10.2.2.1 remote-as 300sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 10.2.2.1 activatesonic(config-router-af)# redistribute connectedVerification
1. PE and ASBR establish an MP-BGP neighbor relationship, transfer VPN routes to each other, establish EBGP between ASBRs, and CE1 and CE2 routes are reachable.
2. CE1 and CE2 can communicate with each other.
Example of MPLS L3VPN OptionB Configuration
Section titled “Example of MPLS L3VPN OptionB Configuration”Networking Requirements
In this network, OSPF and LDP protocols are run between PE1, ASBR1 and PE2, ASBR2 respectively; Further establish EBGP neighbors between PE and CE, MP-IBGP neighbors between PE and ASBR, and MP-EBGP neighbors between two ASBRs, ultimately enabling CE1 and CE2 of the same VPN to communicate with each other.

Configuration Steps
1. PE1 Configuration
# Configure the IP address for the interface, create VRF1, and add the Ethernet1 interface
sonic(config)# vrf 1sonic(config)# interface ethernet 1sonic(config-if-1)# vrf 1sonic(config-if-1)# ip address 10.1.1.1/24sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.1.1.1/24# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 1.1.1.1/32sonic(config)# router ospfsonic(config-router)# ospf router-id 1.1.1.1sonic(config-router)# redistribute connectedsonic(config-router)# network 20.1.1.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 1.1.1.1sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 20.1.1.1# Create MP-BGP and establish neighbors with ASBR1
sonic(config)# router bgp 200sonic(config-router)# neighbor 2.2.2.2 remote-as 200sonic(config-router)# neighbor 2.2.2.2 update-source 1.1.1.1sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# no neighbor 2.2.2.2 activatesonic(config-router-af)# exit-address-familysonic(config-router)# address-family ipv4 vpnsonic(config-router-af)# neighbor 2.2.2.2 activate# Create EBGP and establish neighbors with CE1
sonic(config-router)# router bgp 200 vrf 1sonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 10.1.1.2 remote-as 101sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# label vpn export autosonic(config-router-af)# rd vpn export 200:1sonic(config-router-af)# rt vpn both 1:1sonic(config-router-af)# export vpnsonic(config-router-af)# import vpn2. ASBR1 Configuration
# Configure interface IP address
sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.1.1.2/24sonic(config-if-2)# mpls bgp l3vpn-multi-domain-switchingsonic(config)# interface ethernet 3sonic(config-if-3)# ip address 30.1.1.1/24sonic(config-if-3)# mpls bgp l3vpn-multi-domain-switching# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 2.2.2.2/32sonic(config)# router ospfsonic(config-router)# ospf router-id 2.2.2.2sonic(config-router)# redistribute connectedsonic(config-router)# network 20.1.1.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 2.2.2.2sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 20.1.1.2sonic(config-ldp-af)# interface ethernet 2# Create MP-BGP and establish neighbors with PE1
sonic(config)# router bgp 200sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 1.1.1.1 remote-as 200sonic(config-router)# neighbor 1.1.1.1 update-source 2.2.2.2sonic(config-router)# neighbor 30.1.1.2 remote-as 300sonic(config-router)# neighbor 30.1.1.2 ebgp-multihop 10sonic(config-router)# neighbor 30.1.1.2 update-source 30.1.1.1sonic(config-router)# address-family ipv4 vpnsonic(config-router-af)# neighbor 1.1.1.1 activatesonic(config-router-af)# neighbor 1.1.1.1 next-hop-selfsonic(config-router-af)# neighbor 30.1.1.2 activatesonic(config-router-af)# neighbor 30.1.1.2 next-hop-self3. ASBR2 Configuration
# Configure interface IP address
sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.2.2.2/24sonic(config-if-2)# mpls bgp l3vpn-multi-domain-switchingsonic(config)#interface ethernet 3sonic(config-if-3)# ip address 30.1.1.2/24sonic(config-if-3)# mpls bgp l3vpn-multi-domain-switching# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 3.3.3.3/32sonic(config)# router ospfsonic(config-router)# ospf router-id 3.3.3.3|sonic(config-router)# redistribute connectedsonic(config-router)# network 20.2.2.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 3.3.3.3sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 20.2.2.2sonic(config-ldp-af)# interface ethernet 2# Create MP-BGP and establish neighbors with PE2
sonic(config)# router bgp 300sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 4.4.4.4 remote-as 300sonic(config-router)# neighbor 4.4.4.4 update-source 3.3.3.3sonic(config-router)# neighbor 30.1.1.1 remote-as 200sonic(config-router)# neighbor 30.1.1.1 ebgp-multihop 10sonic(config-router)# neighbor 30.1.1.1 update-source 30.1.1.2sonic(config-router)# address-family ipv4 vpnsonic(config-router-af)# neighbor 4.4.4.4 activatesonic(config-router-af)# neighbor 4.4.4.4 next-hop-selfsonic(config-router-af)# neighbor 30.1.1.1 activatesonic(config-router-af)# neighbor 30.1.1.1 next-hop-self4. PE2 Configuration
# Configure the IP address for the interface, create VRF1, and add the Ethernet1 interface
sonic(config)# vrf 1sonic(config)# interface ethernet 1sonic(config-if-1)# vrf 1sonic(config-if-1)# ip address 10.2.2.1/24sonic(config)# interface ethernet 2sonic(config-if-2)# ip address 20.2.2.1/24# Establish OSPF session
sonic(config)# interface loopback 1sonic(config-if-lo1)# ip address 4.4.4.4/32sonic(config)# router ospfsonic(config-router)# ospf router-id 4.4.4.4sonic(config-router)# redistribute connectedsonic(config-router)# network 20.2.2.0/24 area 1# Enable LDP function
sonic(config)# mpls ldpsonic(config-ldp)# router-id 4.4.4.4sonic(config-ldp)# address-family ipv4sonic(config-ldp-af)# discovery transport-address 20.2.2.1sonic(config-ldp-af)# interface ethernet 2# Create MP-BGP and establish neighbors with ASBR2
sonic(config)# router bgp 300sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 3.3.3.3 remote-as 300sonic(config-router)# neighbor 3.3.3.3 update-source 4.4.4.4sonic(config-router)# address-family ipv4 vpnsonic(config-router-af)# neighbor 3.3.3.3 activate# Create EBGP and establish neighbors with CE2
sonic(config)# router bgp 300 vrf 1sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-req exituires-policysonic(config-router)# neighbor 10.2.2.2 remote-as 102sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 10.2.2.2 activatesonic(config-router-af)# redistribute connectedsonic(config-router-af)# label vpn export 300sonic(config-router-af)# rd vpn export 300:1sonic(config-router-af)# rt vpn both 1:1sonic(config-router-af)# export vpnsonic(config-router-af)# import vpn5. CE1 Configuration
# Configure interface Ethernet1 IP address
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.1.1.2/24# Create EBGP, establish neighbors with PE1, and introduce direct routing
sonic(config)# router bgp 101sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 10.1.1.1 remote-as 200sonic(config-router)# neighbor 10.1.1.1 update-source 10.1.1.2sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 10.1.1.1 activatesonic(config-router-af)# redistribute connected6. CE2 Configuration
# Configure interface Ethernet1 IP address
sonic(config)# interface ethernet 1sonic(config-if-1)# ip address 10.2.2.2/24# Create EBGP, establish neighbors with PE2, and introduce direct routing
sonic(config)# router bgp 102sonic(config-router)# no bgp default ipv4-unicastsonic(config-router)# no bgp ebgp-requires-policysonic(config-router)# neighbor 10.2.2.1 remote-as 300sonic(config-router)# neighbor 10.2.2.1 update-source 10.2.2.2sonic(config-router)# address-family ipv4 unicastsonic(config-router-af)# neighbor 10.2.2.1 activatesonic(config-router-af)# redistribute connectedVerification
1. PE and ASBR establish an MP-BGP neighbor relationship, and ASBR establish MP-BGP to transfer VPN routes to each other. CE1 and CE2 routes can reach.
2. CE1 and CE2 can communicate with each other.