MPLS_Dynamic_LDP

MPLS_Dynamic_LDP

前言

动态的LDP是HCIE的必考内容。在做动态的LDP之间我们最好对静态的LDP要有所了解并进行实验练习。

动态的LDP只不过是通过自动配置标签代替了我们的手工配置标签。

原理

第一步:当我们在接口上激活了LDP之后,那么就可以通过UDP的发送组播hello报文,该报文当中重点有两个信息:第一是ID,第二个是传输地址。

第二步:根据对方hello报文当中的传输地址,传输地址大的要主动建立TCP的会话,即通过三次握手建立TCP会话,通常我们都会用lookback接口做为传输地址,那三次握手成功的前提便是IGP内部的路由通畅。

第三步:会话建立成功之后,

配置

在配置这个章节当中,我们先把OSPF配置完成,然后再来配置LDP.

基础配置


# 基础配置
R1:
	sys
	sysn R1
	int l0
	ip add 10.0.1.1 22
	int g0/0/0
	ip add 10.0.12.1 24
R2:
	sys
	sysn R2
	int l0
	ip add 10.0.2.2 32
	int g0/0/0
	ip add 10.0.12.2 24
	int g0/0/1
	ip add 10.0.23.2 24
R3:
	sys
	sysn R3
	int l0
	ip add 10.0.3.3 32
	int g0/0/0
	ip add 10.0.23.3 24
	int g0/0/1
	ip add 10.0.34.3 24
R4:
	sys
	sysn R4
	int l0
	ip add 10.0.4.4 32
	int g0/0/0
	ip add 10.0.34.4 24
# OSPF的配置
# R1:
ospf 1 router-id 10.0.1.1
a 0
network 10.0.1.1 0.0.0.0
network 10.0.12.1 0.0.0.0
quit
quit
save

# R2:
ospf 1 router-id 10.0.2.2
a 0
network 10.0.2.2 0.0.0.0
network 10.0.12.2 0.0.0.0
network 10.0.23.2 0.0.0.0
quit
quit
save
# R3:
ospf 1 router-id 10.0.3.3
a 0
network 10.0.3.3 0.0.0.0
network 10.0.23.3 0.0.0.0
network 10.0.34.3 0.0.0.0
quit
quit
save
# R4:
ospf 1 router-id 10.0.4.4
a 0
network 10.0.4.4 0.0.0.0
network 10.0.34.4 0.0.0.0
quit
quit

LDP配置

# R1
mpls lsr-id 10.0.1.1  # 配置mpls lsr-id
mpls 				# 全局激活mpls
quit
mpls ldp			# 全局激活ldp
int g0/0/0           # 接口上激活mpls和ldp
	mpls
	mpls ldp
	
# R2
mpls lsr-id 10.0.2.2
mpls
quit
mpls ldp
int g0/0/0
	mpls
	mpls ldp
int g0/0/1
	mpls
	mpls ldp
	
# R3
mpls lsr-id 10.0.3.3
mpls
quit
mpls ldp
int g0/0/0
	mpls
	mpls ldp
int g0/0/1
	mpls
	mpls ldp
	
# R4
mpls lsr-id 10.0.4.4
mpls
quit
mpls ldp
int g0/0/0
	mpls
	mpls ldp

验证配置

# 在R1上查看邻居表,R1发现一个邻居,lsr-id是10.0.2.2,传输地址也是10.0.2.2
[R1]dis mpls ldp peer   # 命令后可加verbose,查看更为详细的信息
 LDP Peer Information in Public network
 A '*' before a peer means the peer is being deleted.
 ------------------------------------------------------------------------------
 PeerID                 TransportAddress   DiscoverySource
 ------------------------------------------------------------------------------
 10.0.2.2:0             10.0.2.2           GigabitEthernet0/0/0
 ------------------------------------------------------------------------------
 TOTAL: 1 Peer(s) Found.
# 在R1上查看TCP的会话信息,双方状态已经达到oprational(正常)
[R1]dis mpls ldp session  # 后面可以加verbose查看更详细的信息

 LDP Session(s) in Public Network
 Codes: LAM(Label Advertisement Mode), SsnAge Unit(DDDD:HH:MM)
 A '*' before a session means the session is being deleted.
 ------------------------------------------------------------------------------
 PeerID             Status      LAM  SsnRole  SsnAge      KASent/Rcv
 ------------------------------------------------------------------------------
 10.0.2.2:0         Operational DU   Passive  0000:00:02  11/11
 ------------------------------------------------------------------------------
 TOTAL: 1 session(s) Found.

# 查看LDP创建的LSP相关信息
<R4>dis mpls ldp lsp
 
 LDP LSP Information
 -------------------------------------------------------------------------------
 DestAddress/Mask   In/OutLabel    UpstreamPeer    NextHop         OutInterface
 -------------------------------------------------------------------------------

 10.0.1.1/32        NULL/1026      -               10.0.34.3       GE0/0/0
 10.0.1.1/32        1026/1026      10.0.3.3        10.0.34.3       GE0/0/0
 10.0.2.2/32        NULL/1025      -               10.0.34.3       GE0/0/0
 10.0.2.2/32        1025/1025      10.0.3.3        10.0.34.3       GE0/0/0
 10.0.3.3/32        NULL/3         -               10.0.34.3       GE0/0/0
 10.0.3.3/32        1024/3         10.0.3.3        10.0.34.3       GE0/0/0
 10.0.4.4/32        3/NULL         10.0.3.3        127.0.0.1       InLoop0  # 看这一行
*10.0.4.4/32        Liberal/1024                   DS/10.0.3.3
 -------------------------------------------------------------------------------
 TOTAL: 7 Normal LSP(s) Found.
 TOTAL: 1 Liberal LSP(s) Found.
 TOTAL: 0 Frr LSP(s) Found.
 A '*' before an LSP means the LSP is not established
 A '*' before a Label means the USCB or DSCB is stale
 A '*' before a UpstreamPeer means the session is stale
 A '*' before a DS means the session is stale
 A '*' before a NextHop means the LSP is FRR LSP

通过上面信息可以看到,好像只有主机路由的相关信息,这是因为华为路由器默认就只给主动路由分配标签。

10.0.4.4这条主动路由的入站标签是3(PHP机制起作用),出站标签是NULL。

R4希望上游路由器在转发到达10.0.4.4的标签报文,提前把标签头弹出。

R3>dis mpls ldp lsp 
 
 LDP LSP Information
 -------------------------------------------------------------------------------
 DestAddress/Mask   In/OutLabel    UpstreamPeer    NextHop         OutInterface
 -------------------------------------------------------------------------------

 10.0.1.1/32        NULL/1026      -               10.0.23.2       GE0/0/0
 10.0.1.1/32        1026/1026      10.0.2.2        10.0.23.2       GE0/0/0
 10.0.1.1/32        1026/1026      10.0.4.4        10.0.23.2       GE0/0/0
*10.0.1.1/32        Liberal/1026                   DS/10.0.4.4
 10.0.2.2/32        NULL/3         -               10.0.23.2       GE0/0/0
 10.0.2.2/32        1025/3         10.0.2.2        10.0.23.2       GE0/0/0
 10.0.2.2/32        1025/3         10.0.4.4        10.0.23.2       GE0/0/0
*10.0.2.2/32        Liberal/1025                   DS/10.0.4.4
 10.0.3.3/32        3/NULL         10.0.4.4        127.0.0.1       InLoop0
 10.0.3.3/32        3/NULL         10.0.2.2        127.0.0.1       InLoop0
*10.0.3.3/32        Liberal/1024                   DS/10.0.4.4
*10.0.3.3/32        Liberal/1024                   DS/10.0.2.2
 10.0.4.4/32        NULL/3         -               10.0.34.4       GE0/0/1
 10.0.4.4/32        1024/3         10.0.4.4        10.0.34.4       GE0/0/1 # 看这里
 10.0.4.4/32        1024/3         10.0.2.2        10.0.34.4       GE0/0/1
*10.0.4.4/32        Liberal/1025                   DS/10.0.2.2
 -------------------------------------------------------------------------------
 TOTAL: 11 Normal LSP(s) Found.
 TOTAL: 5 Liberal LSP(s) Found.
 TOTAL: 0 Frr LSP(s) Found.
 A '*' before an LSP means the LSP is not established
 A '*' before a Label means the USCB or DSCB is stale
 A '*' before a UpstreamPeer means the session is stale
 A '*' before a DS means the session is stale
 A '*' before a NextHop means the LSP is FRR LSP
 
 # 下面这种方式查看更为简单
 <R3>dis mpls lsp
-------------------------------------------------------------------------------
                 LSP Information: LDP LSP
-------------------------------------------------------------------------------
FEC                In/Out Label  In/Out IF                      Vrf Name       
10.0.4.4/32        NULL/3        -/GE0/0/1                                     
10.0.4.4/32        1024/3        -/GE0/0/1                 # 看这里                    
10.0.3.3/32        3/NULL        -/-                                           
10.0.2.2/32        NULL/3        -/GE0/0/0                                     
10.0.2.2/32        1025/3        -/GE0/0/0                                     
10.0.1.1/32        NULL/1026     -/GE0/0/0                                     
10.0.1.1/32        1026/1026     -/GE0/0/0  

在R3上看到对于10.0.4.4,出站标签是3,正好对应着R4上的入站标签,而R3给此条目分配的标签是1024.

<R1>dis mpls lsp
-------------------------------------------------------------------------------
                 LSP Information: LDP LSP
-------------------------------------------------------------------------------
FEC                In/Out Label  In/Out IF                      Vrf Name       
10.0.2.2/32        NULL/3        -/GE0/0/0                                     
10.0.2.2/32        1024/3        -/GE0/0/0                                     
10.0.3.3/32        NULL/1024     -/GE0/0/0                                     
10.0.3.3/32        1025/1024     -/GE0/0/0                                     
10.0.4.4/32        NULL/1025     -/GE0/0/0                                     
10.0.4.4/32        1026/1025     -/GE0/0/0                                     
10.0.1.1/32        3/NULL        -/-                                           

在R1上查看关于10.0.4.4的信息我们会发现,其出站的标签是1025正好对应着R2的入站标签,而本地给它分配的标签是1026.

结果查验

<R1>tracert lsp ip 10.0.4.4 32
  LSP Trace Route FEC: IPV4 PREFIX 10.0.4.4/32 , press CTRL_C to break.
  TTL   Replier            Time    Type      Downstream 
  0                                Ingress   10.0.12.2/[1025 ]
  1     10.0.12.2          10 ms   Transit   10.0.23.3/[1024 ]
  2     10.0.23.3          30 ms   Transit   10.0.34.4/[3 ]
  3     10.0.4.4           60 ms   Egress       

posted @ 2023-02-22 21:33  张贺贺呀  阅读(47)  评论(0编辑  收藏  举报