最近擺弄MPLS,發現很多人配置MPLS只是寫了個簡單的命令,對具體的原理解釋說的很少。我們這篇文章就好好說下。
這是基本的拓撲圖
1.爲什麼開發MPLS技術,它和傳統的ip技術的區別?
我們知道傳統的ip轉發技術是基於路由表的,也就是說一個從入口來的數據包路由要檢查ip 路由表才能做轉發,這樣的IP數據包網絡,在網絡設備傳遞數據包時,是根據數據包的IP包頭信息進行交換的,也就是網絡設備根據包頭中的目標IP地址,來決定從哪個接口轉發出去。所以在數據包當中,指導設備正確轉發數據包的就是IP地址信息,而IP地址只是數據包的一個標識而已!那麼我們爲什麼不能直接打個標籤讓路由通過硬件識別這個tag,從進行轉發,這樣豈不大大節省路由器處理數據包的時間,這就是MPLS產生的原因。不過那時還木有CEF MLS 這樣的技術。
2:MPLS標籤
其中EXP是關於qos相關的,一會說到這個
bos值是指示標籤棧的,一個flow可以有多個標籤,值爲0,如果是棧底,就爲1,在標籤交互過程中只看頂部標籤,這點注意
3.MPLS基本概念
入站LSR:接收沒有標籤的數據包,打上標籤併發出
4.LDP工作流程
LDP是負責標籤轉發的協議,
(1)運行LDP的LSR發現
(2)會話的建立和維護
Protocol version: 1
Downstream label generic region: min label: 16; max label: 100000
Session hold time: 180 sec; keep alive interval: 60 sec
Discovery hello: holdtime: 15 sec; interval: 5 sec
Discovery targeted hello: holdtime: 90 sec; interval: 10 sec
Downstream on Demand max hop count: 255
Downstream on Demand Path Vector Limit: 255
LDP for targeted sessions
LDP initial/maximum backoff: 15/120 sec
LDP loop detection: of
5.標籤的交換過程
明白上下游,數據層面路由層面
R345運行mpls ,R1267ip
R1有個1.1.1.1到R6的6.6.6.6標籤交換
在運行MPLS路由器上有3張表,路由表 cef表 標籤轉發表
R3#show ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
34.0.0.0/24 is subnetted, 1 subnets
C 34.1.1.0 is directly connected, Serial0/3
1.0.0.0/32 is subnetted, 1 subnets
D 1.1.1.1 [90/2297856] via 13.1.1.1, 00:43:06, Serial0/0
3.0.0.0/32 is subnetted, 1 subnets
C 3.3.3.3 is directly connected, Loopback0
4.0.0.0/32 is subnetted, 1 subnets
D 4.4.4.4 [90/2297856] via 34.1.1.4, 00:41:57, Serial0/3
5.0.0.0/32 is subnetted, 1 subnets
D 5.5.5.5 [90/2809856] via 34.1.1.4, 00:41:17, Serial0/3
6.0.0.0/32 is subnetted, 1 subnets
D 6.6.6.6 [90/3321856] via 34.1.1.4, 00:41:09, Serial0/3
56.0.0.0/24 is subnetted, 1 subnets
D 56.1.1.0 [90/3193856] via 34.1.1.4, 00:41:18, Serial0/3
13.0.0.0/24 is subnetted, 1 subnets
C 13.1.1.0 is directly connected, Serial0/0
45.0.0.0/24 is subnetted, 1 subnets
D 45.1.1.0 [90/2681856] via 34.1.1.4, 00:41:23, Serial0/3
R3#show ip cef
Prefix Next Hop Interface
0.0.0.0/0 drop Null0 (default route handler entry)
0.0.0.0/32 receive
1.1.1.1/32 13.1.1.1 Serial0/0
3.3.3.3/32 receive
4.4.4.4/32 34.1.1.4 Serial0/3
5.5.5.5/32 34.1.1.4 Serial0/3
6.6.6.6/32 34.1.1.4 Serial0/3
13.1.1.0/24 attached Serial0/0
13.1.1.0/32 receive
13.1.1.3/32 receive
13.1.1.255/32 receive
34.1.1.0/24 attached Serial0/3
34.1.1.0/32 receive
34.1.1.3/32 receive
34.1.1.255/32 receive
45.1.1.0/24 34.1.1.4 Serial0/3
56.1.1.0/24 34.1.1.4 Serial0/3
224.0.0.0/4 drop
224.0.0.0/24 receive
255.255.255.255/32 receive
R3#show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Untagged 1.1.1.1/32 0 Se0/0 point2point
17 Pop tag 4.4.4.4/32 0 Se0/3 point2point
18 Pop tag 45.1.1.0/24 0 Se0/3 point2point
19 19 5.5.5.5/32 0 Se0/3 point2point
20 20 56.1.1.0/24 0 Se0/3 point2point
22 22 6.6.6.6/32 0 Se0/3 point2point
雖然一條路由可以打了多標籤,但是中間的LSR只根據最頂部的標籤便可以做出轉發。但是,每臺LSR的轉發表裏都會爲一條路由顯示兩個標籤,一個是本地標籤,一個是遠程標籤,要顯示兩個標籤,是因爲一臺LSR收到數據包之後,就查看它的頂部標籤,如果這個標籤是某一條相應的本地標籤,那麼就從相應的接口發出去,同時在發出去的時候,就將數據包的頂部標籤改爲與這個本地標籤對應的遠程標籤
我們從R5上開始看
R5#show mpls for
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 4.4.4.4/32 0 Se0/2 point2point
17 Pop tag 34.1.1.0/24 0 Se0/2 point2point
18 16 3.3.3.3/32 0 Se0/2 point2point
19 17 13.1.1.0/24 0 Se0/2 point2point
20 18 1.1.1.1/32 0 Se0/2 point2point
21 Untagged 6.6.6.6/32 1224 Se0/0 point2point
木有local標籤是21,而出標籤是untagged因爲R6是ip網絡
R4#show mpls for
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 3.3.3.3/32 0 Se0/3 point2point
17 Pop tag 13.1.1.0/24 1152 Se0/3 point2point
18 16 1.1.1.1/32 0 Se0/3 point2point
19 Pop tag 5.5.5.5/32 0 Se0/2 point2point
20 Pop tag 56.1.1.0/24 0 Se0/2 point2point
22 21 6.6.6.6/32 432 Se0/2 point2point
關於6.6.6.6路由條目在R4上local 是22 出標籤21,意思就是凡事收到6.6.6.6路由條目把出標籤是21並從s0/2口轉發出去,我們發現R4的出標籤就是R5的local標籤,這也就是LDP協議的所在
R3#show mpls for
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Untagged 1.1.1.1/32 0 Se0/0 point2point
17 Pop tag 4.4.4.4/32 0 Se0/3 point2point
18 Pop tag 45.1.1.0/24 0 Se0/3 point2point
19 19 5.5.5.5/32 0 Se0/3 point2point
20 20 56.1.1.0/24 0 Se0/3 point2point
22 22 6.6.6.6/32 0 Se0/3 point2point
之所以是兩個22,local那個22是路由隨意打得,木有啥實際意思
6.標籤的定義
隱式空3標籤
7.最後纔是配置命令
mpls label protocol ldp
interface Loopback0
ip address 3.3.3.3 255.255.255.255
interface Serial0/0
ip address 13.1.1.3 255.255.255.0
serial restart-delay 0
interface Serial0/1
ip address 23.1.1.3 255.255.255.0
serial restart-delay 0
interface Serial0/3
ip address 34.1.1.3 255.255.255.0
mpls ip
serial restart-delay 0
router eigrp 100
network 3.3.3.0 0.0.0.255
network 13.1.1.0 0.0.0.255
network 23.1.1.0 0.0.0.255
network 34.1.1.0 0.0.0.255
no auto-summary
mpls ldp router-id Loopback0 force
R3#show mpls int
Interface IP Tunnel Operational
Serial0/3 Yes (ldp) No Yes
還有一點說下
R3#show mpls ldp discovery de
Local LDP Identifier:
3.3.3.3:0
Discovery Sources:
Interfaces:
Serial0/3 (ldp): xmit/recv
Enabled: Interface config
Hello interval: 5000 ms; Transport IP addr: 3.3.3.3 (必須保證可以連通)
LDP Id: 4.4.4.4:0
Src IP addr: 34.1.1.4; Transport IP addr: 4.4.4.4
Hold time: 15 sec; Proposed local/peer: 15/15 sec
Reachable via 4.4.4.4/32