實驗 MPLS LDP配置
一、學習目的
掌握啟用和關閉MPLS的方法
掌握啟用和關閉MPLS LDP配置方法
掌握使用MPLS LDP配置LSP的方法
二、拓撲圖

三、場景
你是公司的網管員,公司的網絡了IP網絡,為解決IP網絡轉發性能低下問題,決定使用MPLS技術來提高
路由器的轉發速度,而靜態LSP由管理員手式配置,LDP是專為標簽發布而制定的標簽分發協議
,為了配置靈活LDP來建議MPLS LSP
步驟一、基本配置與IP編址
給所有路由器和交換機配置IP地址和掩碼
AR1配置腳本 sys sysname AR1 int g0/0/1 ip add 10.0.1.1 24 int s1/0/0 ip add 10.0.12.1 24 int lo0 ip add 2.2.2.2 24 dis ip int br AR2配置腳本 sys sysname AR2 int s1/0/0 ip add 10.0.12.2 24 int s2/0/0 ip add 10.0.23.2 24 int lo0 ip add 3.3.3.3 24 dis ip int br AR3配置腳本 sys sysname AR3 int s2/0/0 ip add 10.0.23.3 24 int g0/0/1 ip add 10.0.2.1 24 int lo0 ip add 4.4.4.4 24 dis ip int br SW1配置腳本 sys sysname SW1 int vlanif 1 ip add 10.0.1.2 24 sw2配置腳本 sys sysname SW2 int vlanif 1 ip add 10.0.2.2 24
步驟二、配置單區域OSPF
配置10.0.12.0/24
10.0.23.0/24
10.0.1.0/24
10.0.2.0/24四個網段屬於OSPF區域0
AR1 sys ospf 1 router-id 2.2.2.2 area 0 network 10.0.1.0 0.0.0.255 network 10.0.12.0 0.0.0.255 network 2.2.2.0 0.0.0.255 AR2 sys ospf 1 router-id 3.3.3.3 area 0 network 10.0.12.0 0.0.0.255 network 10.0.23.0 0.0.0.255 network 3.3.3.0 0.0.0.255 AR3 sys ospf 1 router-id 4.4.4.4 area 0 network 10.0.23.0 0.0.0.255 network 10.0.2.0 0.0.0.255 network 4.4.4.0 0.0.0.255 dis ospf brief SW1 sys ospf 1 router-id 1.1.1.1 area 0 network 10.0.1.0 0.0.0.255 SW2 sys ospf 1 router-id 5.5.5.5 area 0 network 10.0.2.0 0.0.0.255
配置完成后,查看設備的路由表,並測試全網的連通性
[AR2]dis ip routing-table Route Flags: R - relay, D - download to fib ------------------------------------------------------------------------------ Routing Tables: Public Destinations : 17 Routes : 17 Destination/Mask Proto Pre Cost Flags NextHop Interface 3.3.3.0/24 Direct 0 0 D 3.3.3.3 LoopBack0 3.3.3.3/32 Direct 0 0 D 127.0.0.1 LoopBack0 3.3.3.255/32 Direct 0 0 D 127.0.0.1 LoopBack0 10.0.1.0/24 OSPF 10 49 D 10.0.12.1 Serial1/0/0 10.0.2.0/24 OSPF 10 49 D 10.0.23.3 Serial2/0/0 10.0.12.0/24 Direct 0 0 D 10.0.12.2 Serial1/0/0 10.0.12.1/32 Direct 0 0 D 10.0.12.1 Serial1/0/0 10.0.12.2/32 Direct 0 0 D 127.0.0.1 Serial1/0/0 10.0.12.255/32 Direct 0 0 D 127.0.0.1 Serial1/0/0 10.0.23.0/24 Direct 0 0 D 10.0.23.2 Serial2/0/0 10.0.23.2/32 Direct 0 0 D 127.0.0.1 Serial2/0/0 10.0.23.3/32 Direct 0 0 D 10.0.23.3 Serial2/0/0 10.0.23.255/32 Direct 0 0 D 127.0.0.1 Serial2/0/0 127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0 127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0 127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0 [SW1]ping 10.0.2.2 PING 10.0.2.2: 56 data bytes, press CTRL_C to break Reply from 10.0.2.2: bytes=56 Sequence=1 ttl=252 time=200 ms Reply from 10.0.2.2: bytes=56 Sequence=2 ttl=252 time=60 ms Reply from 10.0.2.2: bytes=56 Sequence=3 ttl=252 time=50 ms Reply from 10.0.2.2: bytes=56 Sequence=4 ttl=252 time=70 ms Reply from 10.0.2.2: bytes=56 Sequence=5 ttl=252 time=60 ms --- 10.0.2.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 50/88/200 ms [AR2]ping 10.0.1.2 PING 10.0.1.2: 56 data bytes, press CTRL_C to break Reply from 10.0.1.2: bytes=56 Sequence=1 ttl=254 time=70 ms Reply from 10.0.1.2: bytes=56 Sequence=2 ttl=254 time=20 ms Reply from 10.0.1.2: bytes=56 Sequence=3 ttl=254 time=40 ms Reply from 10.0.1.2: bytes=56 Sequence=4 ttl=254 time=50 ms Reply from 10.0.1.2: bytes=56 Sequence=5 ttl=254 time=20 ms --- 10.0.1.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 20/40/70 ms [AR2]ping 10.0.2.2 PING 10.0.2.2: 56 data bytes, press CTRL_C to break Reply from 10.0.2.2: bytes=56 Sequence=1 ttl=254 time=50 ms Reply from 10.0.2.2: bytes=56 Sequence=2 ttl=254 time=20 ms Reply from 10.0.2.2: bytes=56 Sequence=3 ttl=254 time=20 ms Reply from 10.0.2.2: bytes=56 Sequence=4 ttl=254 time=30 ms Reply from 10.0.2.2: bytes=56 Sequence=5 ttl=254 time=20 ms --- 10.0.2.2 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 20/28/50 ms
步驟三、MPLS LDP配置
在各MPLS路由器上配置全局MPLS和LDP
###AR1 sys mpls lsr-id 2.2.2.2 mpls mpls ldp ###AR2 sys mpls lsr-id 3.3.3.3 mpls mpls ldp ###AR3 sys mpls lsr-id 4.4.4.4 mpls mpls ldp
在各MPLS路由器接口上配置MPLS和LDP
###AR1 sys int s1/0/0 mpls mpls ldp ###AR2 sys int s1/0/0 mpls mpls ldp int s2/0/0 mpls mpls ldp ###AR3 sys int s2/0/0 mpls mpls ldp
配置完成后 在節點上執行display mpls ldp session
命令,可以看到R1和R2 R3之間的本地LDP會話狀態為“operational"
AR1]dis mpls ldp session 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 ------------------------------------------------------------------------------ 3.3.3.3:0 Operational DU Passive 0000:00:03 15/15 ------------------------------------------------------------------------------ TOTAL: 1 session(s) Found. [AR2-Serial2/0/0]dis mpls ldp session 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 ------------------------------------------------------------------------------ 2.2.2.2:0 Operational DU Active 0000:00:01 6/6 4.4.4.4:0 Operational DU Passive 0000:00:01 5/5 ------------------------------------------------------------------------------ TOTAL: 2 session(s) Found. [AR2-Serial2/0/0]dis mpls ldp session 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 ------------------------------------------------------------------------------ 2.2.2.2:0 Operational DU Active 0000:00:04 17/17 4.4.4.4:0 Operational DU Passive 0000:00:03 16/16 ------------------------------------------------------------------------------ TOTAL: 2 session(s) Found. [AR3]display mpls ldp session 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 ------------------------------------------------------------------------------ 3.3.3.3:0 Operational DU Active 0000:00:04 17/17 ------------------------------------------------------------------------------ TOTAL: 1 session(s) Found.
步驟四、LDP建立LSP
在配置完成后,各MPLS路由器已經根據默認的LDP觸發策略建立LSP。即所有主機路由觸發
建立 LDP LSP
在各MPLS路由器上執行display mpls ldp lsp命令,可以看到所有主機路由都觸發建立了
LDP LSP
[AR1]dis mpls ldp lsp LDP LSP Information ------------------------------------------------------------------------------- DestAddress/Mask In/OutLabel UpstreamPeer NextHop OutInterface ------------------------------------------------------------------------------- 2.2.2.2/32 3/NULL 3.3.3.3 127.0.0.1 InLoop0 *2.2.2.2/32 Liberal/1024 DS/3.3.3.3 3.3.3.3/32 NULL/3 - 10.0.12.2 S1/0/0 3.3.3.3/32 1024/3 3.3.3.3 10.0.12.2 S1/0/0 4.4.4.4/32 NULL/1025 - 10.0.12.2 S1/0/0 4.4.4.4/32 1025/1025 3.3.3.3 10.0.12.2 S1/0/0 ------------------------------------------------------------------------------- TOTAL: 5 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 [AR2]dis mpls ldp lsp LDP LSP Information ------------------------------------------------------------------------------- DestAddress/Mask In/OutLabel UpstreamPeer NextHop OutInterface ------------------------------------------------------------------------------- 2.2.2.2/32 NULL/3 - 10.0.12.1 S1/0/0 2.2.2.2/32 1024/3 2.2.2.2 10.0.12.1 S1/0/0 2.2.2.2/32 1024/3 4.4.4.4 10.0.12.1 S1/0/0 *2.2.2.2/32 Liberal/1024 DS/4.4.4.4 3.3.3.3/32 3/NULL 2.2.2.2 127.0.0.1 InLoop0 3.3.3.3/32 3/NULL 4.4.4.4 127.0.0.1 InLoop0 *3.3.3.3/32 Liberal/1024 DS/2.2.2.2 *3.3.3.3/32 Liberal/1025 DS/4.4.4.4 4.4.4.4/32 NULL/3 - 10.0.23.3 S2/0/0 4.4.4.4/32 1025/3 2.2.2.2 10.0.23.3 S2/0/0 4.4.4.4/32 1025/3 4.4.4.4 10.0.23.3 S2/0/0 *4.4.4.4/32 Liberal/1025 DS/2.2.2.2 ------------------------------------------------------------------------------- TOTAL: 8 Normal LSP(s) Found. TOTAL: 4 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 [AR3]dis mpls ldp lsp LDP LSP Information ------------------------------------------------------------------------------- DestAddress/Mask In/OutLabel UpstreamPeer NextHop OutInterface ------------------------------------------------------------------------------- 2.2.2.2/32 NULL/1024 - 10.0.23.2 S2/0/0 2.2.2.2/32 1024/1024 3.3.3.3 10.0.23.2 S2/0/0 3.3.3.3/32 NULL/3 - 10.0.23.2 S2/0/0 3.3.3.3/32 1025/3 3.3.3.3 10.0.23.2 S2/0/0 4.4.4.4/32 3/NULL 3.3.3.3 127.0.0.1 InLoop0 *4.4.4.4/32 Liberal/1025 DS/3.3.3.3 ------------------------------------------------------------------------------- TOTAL: 5 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
通常情況下,使用缺省的觸發的策略,即由”HOST“方式觸發建立 LDP LSP
在各MPLS路由上將LDP LSP的觸發策略修改為all,使路由表中的所有靜態路由和IGP表項
都可以觸發建立LDP LSP。
##R1
sys
mpls
lsp-trigger all
##R2
sys
mpls
lsp-trigger all
##R3
sys
mpls
lsp-trigger all
s配置完成后,在各節點上執行display mpls ldp lsp 命令。可以看到ldp lsp的建立情況
[AR1]dis mpls ldp lsp LDP LSP Information ------------------------------------------------------------------------------- DestAddress/Mask In/OutLabel UpstreamPeer NextHop OutInterface ------------------------------------------------------------------------------- 2.2.2.0/24 3/NULL 3.3.3.3 2.2.2.2 Loop0 2.2.2.2/32 3/NULL 3.3.3.3 127.0.0.1 InLoop0 *2.2.2.2/32 Liberal/1024 DS/3.3.3.3 *3.3.3.0/24 Liberal/3 DS/3.3.3.3 3.3.3.3/32 NULL/3 - 10.0.12.2 S1/0/0 3.3.3.3/32 1024/3 3.3.3.3 10.0.12.2 S1/0/0 4.4.4.4/32 NULL/1025 - 10.0.12.2 S1/0/0 4.4.4.4/32 1025/1025 3.3.3.3 10.0.12.2 S1/0/0 10.0.1.0/24 3/NULL 3.3.3.3 10.0.1.1 GE0/0/1 *10.0.1.0/24 Liberal/1026 DS/3.3.3.3 10.0.2.0/24 NULL/1027 - 10.0.12.2 S1/0/0 10.0.2.0/24 1027/1027 3.3.3.3 10.0.12.2 S1/0/0 10.0.12.0/24 3/NULL 3.3.3.3 10.0.12.1 S1/0/0 *10.0.12.0/24 Liberal/3 DS/3.3.3.3 10.0.23.0/24 NULL/3 - 10.0.12.2 S1/0/0 10.0.23.0/24 1026/3 3.3.3.3 10.0.12.2 S1/0/0 ------------------------------------------------------------------------------- TOTAL: 12 Normal LSP(s) Found. TOTAL: 4 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 [AR2]dis mpls ldp lsp LDP LSP Information ------------------------------------------------------------------------------- DestAddress/Mask In/OutLabel UpstreamPeer NextHop OutInterface ------------------------------------------------------------------------------- *2.2.2.0/24 Liberal/3 DS/2.2.2.2 2.2.2.2/32 NULL/3 - 10.0.12.1 S1/0/0 2.2.2.2/32 1024/3 2.2.2.2 10.0.12.1 S1/0/0 2.2.2.2/32 1024/3 4.4.4.4 10.0.12.1 S1/0/0 *2.2.2.2/32 Liberal/1024 DS/4.4.4.4 3.3.3.0/24 3/NULL 2.2.2.2 3.3.3.3 Loop0 3.3.3.0/24 3/NULL 4.4.4.4 3.3.3.3 Loop0 3.3.3.3/32 3/NULL 2.2.2.2 127.0.0.1 InLoop0 3.3.3.3/32 3/NULL 4.4.4.4 127.0.0.1 InLoop0 *3.3.3.3/32 Liberal/1024 DS/2.2.2.2 *3.3.3.3/32 Liberal/1025 DS/4.4.4.4 *4.4.4.0/24 Liberal/3 DS/4.4.4.4 4.4.4.4/32 NULL/3 - 10.0.23.3 S2/0/0 4.4.4.4/32 1025/3 2.2.2.2 10.0.23.3 S2/0/0 4.4.4.4/32 1025/3 4.4.4.4 10.0.23.3 S2/0/0 *4.4.4.4/32 Liberal/1025 DS/2.2.2.2 10.0.1.0/24 NULL/3 - 10.0.12.1 S1/0/0 10.0.1.0/24 1026/3 2.2.2.2 10.0.12.1 S1/0/0 10.0.1.0/24 1026/3 4.4.4.4 10.0.12.1 S1/0/0 *10.0.1.0/24 Liberal/1026 DS/4.4.4.4 10.0.2.0/24 NULL/3 - 10.0.23.3 S2/0/0 10.0.2.0/24 1027/3 2.2.2.2 10.0.23.3 S2/0/0 10.0.2.0/24 1027/3 4.4.4.4 10.0.23.3 S2/0/0 *10.0.2.0/24 Liberal/1027 DS/2.2.2.2 10.0.12.0/24 3/NULL 2.2.2.2 10.0.12.2 S1/0/0 10.0.12.0/24 3/NULL 4.4.4.4 10.0.12.2 S1/0/0 *10.0.12.0/24 Liberal/3 DS/2.2.2.2 *10.0.12.0/24 Liberal/1027 DS/4.4.4.4 10.0.23.0/24 3/NULL 2.2.2.2 10.0.23.2 S2/0/0 10.0.23.0/24 3/NULL 4.4.4.4 10.0.23.2 S2/0/0 *10.0.23.0/24 Liberal/1026 DS/2.2.2.2 *10.0.23.0/24 Liberal/3 DS/4.4.4.4 ------------------------------------------------------------------------------- TOTAL: 20 Normal LSP(s) Found. TOTAL: 12 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
步驟五、LDP inbound策略配置
R1性能較低如果不對R1收到的標簽進行控制,則會建立大量的LSP。
消耗大量內存,R1無法承受
配置LDP inbound策略,R1只接收R2標簽映射消息,使R1只建立到R2的LSP,從而減少資源的浪費
在R1上配置inbound策略只允許到R2的路由通過
##R1
sys
ip ip-prefix prefix1 permit 10.0.12.0 24
mpls ldp
inbound peer 3.3.3.3 fec ip-prefix prefix1
quit
dis mpls lsp
<AR1>sys
Enter system view, return user view with Ctrl+Z.
[AR1]
[AR1]ip ip-prefix prefix1 permit 10.0.12.0 24
[AR1]
[AR1]mpls ldp
[AR1-mpls-ldp]
[AR1-mpls-ldp]inbound peer 3.3.3.3 fec ip-prefix prefix1
[AR1-mpls-ldp]
[AR1-mpls-ldp]quit
[AR1]
[AR1]dis mpls lsp
-------------------------------------------------------------------------------
LSP Information: LDP LSP
-------------------------------------------------------------------------------
FEC In/Out Label In/Out IF Vrf Name
2.2.2.2/32 3/NULL -/-
10.0.1.0/24 3/NULL -/-
10.0.12.0/24 3/NULL -/-
2.2.2.0/24 3/NULL -/-
