以下是基于华为交换机的配置MPLS的代码示例:
- 开启MPLS功能
system-view
[Switch] mpls
[Switch-mpls] quit
- 配置MPLS标签交换协议(LDP)
system-view
[Switch] mpls
[Switch-mpls] ldp
[Switch-mpls-ldp] quit
- 配置MPLS VPN
system-view
[Switch] mpls
[Switch-mpls] vpn-instance vpn1
[Switch-mpls-vpn-instance-vpn1] quit
- 配置MPLS前缀交换协议(MP-BGP)
system-view
[Switch] bgp 65001
[Switch-bgp-65001] ipv4-family vpn-instance vpn1
[Switch-bgp-65001-af-vpn1] quit
[Switch-bgp-65001] ipv4-family vpn-instance vpn1
[Switch-bgp-65001-af-vpn1] peer 192.168.1.1 as-number 65002
[Switch-bgp-65001-af-vpn1] quit
- 配置MPLS标签分配协议(RSVP-TE)
system-view
[Switch] mpls
[Switch-mpls] rsvp-te
[Switch-mpls-rsvp-te] quit
- 配置MPLS-TE隧道
system-view
[Switch] mpls
[Switch-mpls] te
[Switch-mpls-te] tunnel-policy tp1
[Switch-mpls-te] quit
- 配置MPLS-TE隧道路径
system-view
[Switch] mpls
[Switch-mpls] te
[Switch-mpls-te] tunnel-policy tp1
[Switch-mpls-te-tp1] destination 192.168.1.1
[Switch-mpls-te-tp1] primary-path option 1
[Switch-mpls-te-tp1] quit
这些是基本的MPLS配置命令,具体的配置还需要根据实际需求进行相应的调整和优化