一:
MPLS:多协议 标签 交换 (机制)
ldp:标签分发协议 mpls中具体干活的
lsr :当普通路由器运行mpls以后,就变成lsr lable switch router
结构:
label - 20bit
experimental - 3bit
bottom of statck - 1bit
TTL - 8bit
应用:
-代替传统的IP路由转发
-MPLS - VPN
.
二:
MPLS的配置:
1.确保IGP是互通的(前提)
2.为 MPLS 路由器 指定 LSR-ID(lsr-id一定是一个真实的IP地址)
3.全局启用MPLS
4.全局启用 LDP
5.接口启用MPLS
6.接口启用 LDP
每一个路由器:
mpls lsr-id x.x.x.x [该接口在设备上必须是 32位掩码]
mpls 全局
quit
mpls ldp 全局
quit
interface gi0/0/x [内部设备之间的互联接口]
mpls
mpls ldp
quit
route recursive-lookup tunnel 该命令应用在 MPLS 网络的边界设备。
当MPLS 运行成功之后,
LSR 在接收并处理数据包时:
-如果接收到的数据包是纯IP数据包,直接查找路由表,
display ip routing-table ( RIB )
display fib 10.10.6.6 verbose -> 确定该数据包所使用
tunnel id : 0x9
( FIB - 才会有标签;)
display mpls lsp verbose ->去查找和确认 tunnel id
为 0x9 的条目,
从而为了确定出向的接口
以及 MPLS 标签;
-如果接收到的数据包是标签数据包,直接查找标签转发表,
display mpls lsp (label switch path )
MPLS中的 LDP 仅仅为 非BGP 路由分配标签,
当MPLS 路由器接收到去往 BGP 路由条目的数据包时,
使用的标签是 该BGP 路由条目的 下一跳 IP 所对应的标签。
配置如下:
R1:
undo terminal monitor
system-view
sysname R1
interface loopback 0
ip address 10.10.1.1 32
quit
interface gi0/0/0
ip address 192.168.12.1 24
quit
bgp 100
router-id 1.1.1.1
peer 192.168.12.2 as-number 200
network 10.10.1.1 32
quit
R2
undo terminal monitor
system-view
sysname R2
interface loopback 0
ip add 10.10.2.2 32
quit
mpls lsr-id 10.10.2.2 指定lsr的id,此处id为真是存在的ip
mpls 全局开启mpls
quit
mpls ldp 全局开启 ldp
quit
interface gi0/0/1
ip address 192.168.12.2 24
quit
interface gi0/0/0
ip address 192.168.23.2 24
mpls 接口开启mpls
mpls ldp 接口开启ldp
quit
route recursive-lookup tunnel 边界lsr添加此命令
rip
version 2
network 10.0.0.0
network 192.168.23.0
quit
bgp 200
router-id 2.2.2.2
peer 192.168.12.1 as-number 100
peer 10.10.5.5 as-number 200
peer 10.10.5.5 connect-interface loopback 0
peer 10.10.5.5 next-hop-local
quit
R3
undo terminal monitor
system-view
sysname R3
interface loopback 0
ip add 10.10.3.3 32
quit
mpls lsr-id 10.10.3.3
mpls
mpls ldp
interface gi0/0/1
ip address 192.168.23.3 24
mpls
mpls ldp
quit
interface gi0/0/0
ip address 192.168.34.3 24
mpls
mpls ldp
quit
rip
version 2
network 10.0.0.0
network 192.168.23.0
network 192.168.34.0
quit
R4
undo terminal monitor
system-view
sysname R4
mpls lsr-id 10.10.4.4
mpls
mpls ldp
interface loopback 0
ip add 10.10.4.4 32
quit
interface gi0/0/1
ip address 192.168.34.4 24
mpls
mpls ldp
quit
interface gi0/0/0
ip address 192.168.45.4 24
mpls
mpls ldp
quit
rip
version 2
network 10.0.0.0
network 192.168.34.0
network 192.168.45.0
quit
R5
undo terminal monitor
system-view
sysname R5
mpls lsr-id 10.10.5.5
mpls
mpls ldp
interface loopback 0
ip add 10.10.5.5 32
quit
interface gi0/0/1
ip address 192.168.45.5 24
mpls
mpls ldp
route recursive-lookup tunnel
quit
interface gi0/0/0
ip address 192.168.56.5 24
quit
rip
version 2
network 10.0.0.0
network 192.168.45.0
quit
bgp 200
router-id 5.5.5.5
peer 192.168.56.6 as-number 600
peer 10.10.2.2 as-number 200
peer 10.10.2.2 connect-interface loopback 0
peer 10.10.2.2 next-hop-local
quit
R6
undo terminal monitor
system-view
sysname R6
interface loopback 0
ip address 10.10.6.6 32
quit
interface gi0/0/1
ip address 192.168.56.6 24
quit
bgp 600
router-id 6.6.6.6
peer 192.168.56.5 as-number 200
network 10.10.6.6 32
quit
此时ping -a 10.10.1.1 10.6.6.6 可以ping通
以下通过抓包看标签传输的过程
ping时抓包,R2 - R3之间的链路
初始标签1026
在R2上 display mpls lsp 查看出去的out标签 去往10.10.5.5 的也为1026.同时是R3里in的标签
LSP Information: LDP LSP
FEC In/Out Label In/Out IF Vrf Name
10.10.3.3/32 NULL/3 -/GE0/0/0
10.10.3.3/32 1024/3 -/GE0/0/0
10.10.2.2/32 3/NULL -/-
10.10.4.4/32 NULL/1025 -/GE0/0/0
10.10.4.4/32 1025/1025 -/GE0/0/0
10.10.5.5/32 NULL/1026 -/GE0/0/0
10.10.5.5/32 1026/1026 -/GE0/0/0
同时是R3里in的标签
FEC In/Out Label In/Out IF Vrf Name
10.10.3.3/32 3/NULL -/-
10.10.2.2/32 NULL/3 -/GE0/0/1
10.10.2.2/32 1024/3 -/GE0/0/1
10.10.4.4/32 NULL/3 -/GE0/0/0
10.10.4.4/32 1025/3 -/GE0/0/0
10.10.5.5/32 NULL/1026 -/GE0/0/0
10.10.5.5/32 1026/1026 -/GE0/0/0