news 2026/5/30 14:04:06

MPLS LDP基础实验

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
MPLS LDP基础实验

MPLS实验建议使用Router路由器,可以进入diagnose模式,支持更多mpls命令。AR不支持

默认只为32位主机路由分配标签,使用lsp-trigger all为所有路由分配标签

R1R2R3
#
mpls lsr-id 1.1.1.1
mpls
lsp-trigger all
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip address 10.1.12.1 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet0/0/2
ip address 192.168.1.1 255.255.255.0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
ospf 1 router-id 1.1.1.1
silent-interface GigabitEthernet0/0/2
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 10.1.12.1 0.0.0.0
network 192.168.1.1 0.0.0.0
#
#
mpls lsr-id 2.2.2.2
mpls
#
mpls ldp
#
interface GigabitEthernet0/0/0
ip address 10.1.12.2 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet0/0/1
ip address 10.1.23.2 255.255.255.0
mpls
mpls ldp
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 10.1.12.2 0.0.0.0
network 10.1.23.2 0.0.0.0
#

#
mpls lsr-id 3.3.3.3
mpls
lsp-trigger all
#
mpls ldp
#

interface GigabitEthernet0/0/1
ip address 10.1.23.3 255.255.255.0
mpls
mpls ldp
#
interface GigabitEthernet0/0/2
ip address 172.16.1.1 255.255.255.0
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
ospf 1 router-id 3.3.3.3
silent-interface GigabitEthernet0/0/2
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 10.1.23.3 0.0.0.0
network 172.16.1.1 0.0.0.0
#

如果要使用ip-prefix进行过滤,需要允许所有LSR的对应lsr-id地址和业务地址,否则业务数据进不了MPLS

R1R2R3
#
mpls lsr-id 1.1.1.1
mpls
lsp-trigger ip-prefix 1
#
ip ip-prefix 1 index 10 permit 1.1.1.1 32
ip ip-prefix 1 index 20 permit 3.3.3.3 32
ip ip-prefix 1 index 30 permit 2.2.2.2 32
ip ip-prefix 1 index 40 permit 192.168.1.0 24
ip ip-prefix 1 index 50 permit 172.16.1.0 24

#

#
mpls lsr-id 3.3.3.3
mpls
lsp-trigger ip-prefix 1
#
ip ip-prefix 1 index 10 permit 1.1.1.1 32
ip ip-prefix 1 index 20 permit 3.3.3.3 32
ip ip-prefix 1 index 30 permit 2.2.2.2 32
ip ip-prefix 1 index 40 permit 192.168.1.0 24
ip ip-prefix 1 index 50 permit 172.16.1.0 24

#

优化机制:PHP倒数第二跳弹出,通过隐式标签实现,为直连路由分配特殊标签3。

标签类型:

隐式空标签implicit-null:标签值3,便数第2跳弹出,携带的QoS信息将丢失。默认

显式空标签explicit-null:标签值0,携带QoS信息。

正常标签non-null:正常分配。

改为显式空标签后,可以抓到携带MPLS标签的回包。如果是隐藏空标签,在R2上倒数第二跳弹出后,就抓不到携带MPLS标签的回包。

数据转发流程(R1上目标地址为172.16.1.0/24为例):

ingress lsr上R1,先查fib找到tunnel id,再查nhlfe找到标签映射

对应的动作为push压入标签1031,发给下一跳10.1.12.2

transit lsr上R2,先查ilm表找到tunnel id,再查nhlfe找到标签映射

把标签从1031交换为0,发给下一跳10.1.23.3

egress lsr上R3,先查找ilm找到对应tunnel id,再查fib进行转发

未找到对应的项,则tunnel id为0,查fib表转发

从g0/0/2转发

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!