MPLS實驗總結

想了好久才決定要寫這篇文章。由於我感受有好多能夠說,而且要寫出博文有點困難。仍是盡力吧,不寫出來可能也很快就忘了。網絡

按照個人習慣是先上拓撲:dom

這就是個人拓撲。ide

實驗參數以下:oop

IGP用OSPF,實現全網互通。學習

所有路由器都僱用CEF。字體

R1用LOOPBACK 1  =11.1.1.1 模擬外網,R5用loopback 1=55.5.5.5 模擬外網。rest

配置OSPF不做說明。router

先介紹配置MPLS 。blog

R1  和R5創建IGBP關係。接口

在配置過程當中我會故意放入一些不優的配置,以便分析。

R1#ip cef

mpls label range 100 199 這一條命令在實際應用中不要啓用。在這裏只是爲了試驗一下這條命令而已。MPLS的LDP協議是自動爲咱們分配標籤的,這條命令的做用在於指定標籤的範圍。

mpls ldp router-id Loopback1   (記住Loopback1 沒有NETWORK進BGP和OSPF的,是爲了模擬來自CE的路由)

no mpls ip propagate-ttl forwarded 這條命令也很重要。 下面這一段講解這一條命令的做用:、

  1. no mpls ip propagate-ttl forwarded  
  2. 這條命令的意思是,不看IP包的TTL值,由於在PE上,MPLS會copy  IP包中的TTL值填充MPLS包頭
  3. 中的TTL字段。 
  4. 例如當一個數據包進入MPLS網絡時,也就是剛進入PE。 
  5. 假設IP包中的TTL值=6,這時PE先減去1 ,TTL=6-1=5。而後將TTL填充進MPLS包頭的TTL,所
  6. 以這時MPLS包頭的TTL值就是5。 
  7. 以後在MPLS網絡中傳輸時,由於在MPLS網絡中是不看IP包頭的,因此IP包頭的TTL值不會減小,但
  8. 是MPLS的TTL值每通過一個路由器就減小1,(當減小爲0時丟棄。其實當路由器收到一個TTL=1的
  9. 包時就要丟棄了。)最後,在鏈接目的網絡的PE上面,MPLS包頭的TTL值先減去1 ,以後再copy
  10. 回去覆蓋了IP包頭的TTL字段。這樣子的話,在外部網絡的用戶就能夠tracert  MPLS網絡,得知
  11. MPLS網絡的結構。 
  12. 因此咱們須要這條no mpls ip propagate-ttl forwarded 命令,不要從IP包中複製TTL值,
  13. 直接填充MPLS的TTL=255. 
  14. Traceroute就是利用TTL的技術來實現的,第一次發包TTL是1,包到達下一跳後,TTL變成0,包
  15. 被丟棄,並響應一個TTL超時。而後,依次遞增TTL,依次響應TTL超時,就能發現路徑了。若是ISP
  16. 網絡沒有禁用TTL,那麼客戶就能夠利用Traceroute探查到ISP的內部路由了,啓用以下命令,防止
  17. 該事情發生。 
  18.   forwarded是指NO掉CE過來的TTL值,local是指本身的也要NO掉,通常在邊界路由器打上
  19. forwarded就好,保證本身仍是能夠traceroute的,默認不打,兩個所有NO掉。 
  20. MPLS的每一個技術解釋起來都有一大堆話,或許是我太囉嗦了== 

#router bgp 100

no synchronization

bgp router-id 1.1.1.1

bgp log-neighbor-changes

network 11.1.1.0 mask 255.255.255.0

neighbor 45.1.1.5 remote-as 100

  no auto-summary

!        

!        

interface Serial0/0

ip address 12.1.1.1 255.255.255.0

mpls ldp discovery transport-address interface

  1. 這條命令的做用是用接口的地址與鄰居創建LDP關係。使用直鏈接口地址可保證下 一跳可達。
  2. 創建以後在R2上:
    • R2#show mpls  ldp  discovery 
    • Local LDP Identifier:
    •     2.2.2.2:0
    •     Discovery Sources:
    •     Interfaces:
    •         Serial0/0 (ldp): xmit/recv
    •             LDP Id: 11.1.1.1:0; IP addr: 12.1.1.1; no host route
    •         FastEthernet1/0 (ldp): xmit/recv
    •             LDP Id: 3.3.3.3:0; no host route
    • 顯示no host route 是正常的。

mpls ip 

serial restart-delay 0

!        

R2:

ip cef

no ip domain lookup

mpls label range 200 299

mpls ldp router-id Loopback0

R3:

ip cef

no ip domain lookup

mpls label range 300 399

mpls ldp router-id Loopback0

R4:

ip cef

no ip domain lookup

mpls label range 400 499

mpls ldp router-id Loopback0

R5:

ip cef

mpls label range 500 599

no mpls ip propagate-ttl forwarded

interface Loopback0

ip address 5.5.5.5 255.255.255.0

interface Loopback1

ip address 55.5.5.5 255.255.255.0

ip ospf network point-to-point

!        

interface Serial0/0

ip address 45.1.1.5 255.255.255.0

mpls ldp discovery transport-address interface

mpls ip 

serial restart-delay 0

router ospf 100

router-id 5.5.5.5

log-adjacency-changes

network 5.5.5.5 0.0.0.0 area 0

network 45.1.1.5 0.0.0.0 area 0

!        

router bgp 100

no synchronization

bgp router-id 5.5.5.5

bgp log-neighbor-changes

network 55.5.5.0 mask 255.255.255.0

neighbor 12.1.1.1 remote-as 100

no auto-summary

mpls ldp router-id Loopback1

!        

大致的配置已經帖出來了。

下面講一個其中的關健點,次末節路由的一個問題。

注意一下個人BPG配置中創建鄰居的IP地址,是對方的接口地址。

neighbor 45.1.1.5 remote-as 100

neighbor 12.1.1.1 remote-as 100

學習MPLS最難的是跟蹤標籤。下面咱們就來跟蹤一下標籤。

  1. R1#show mpls  forwarding-table  
  2. Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop    
  3. tag    tag or VC   or Tunnel Id      switched   interface              
  4. 100    200         34.1.1.0/24       0          Se0/0      point2point  
  5. 101    Untagged    2.2.2.2/32        0          Se0/0      point2point  
  6. 102    202         3.3.3.3/32        0          Se0/0      point2point  
  7. 103    203         4.4.4.4/32        0          Se0/0      point2point  
  8. 104    204         5.5.5.5/32        0          Se0/0      point2point  
  9. 105    Pop tag     23.1.1.0/24       0          Se0/0      point2point  
  10. 106    205         45.1.1.0/24       0          Se0/0      point2point  
  1. R2#show mpls  forwarding-table 
  2. Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop    
  3. tag    tag or VC   or Tunnel Id      switched   interface              
  4. 200    Pop tag     34.1.1.0/24       0          Fa1/0      23.1.1.3     
  5. 201    Untagged    1.1.1.1/32        0          Se0/0      point2point  
  6. 202    Untagged    3.3.3.3/32        0          Fa1/0      23.1.1.3     
  7. 203    302         4.4.4.4/32        0          Fa1/0      23.1.1.3     
  8. 204    Untagged    5.5.5.5/32        0          Fa1/0      23.1.1.3     
  9. 205    305         45.1.1.0/24       0          Fa1/0      23.1.1.3     
  10. R2#
  1. R3#show mpls  for 
  2. Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop    
  3. tag    tag or VC   or Tunnel Id      switched   interface              
  4. 300    201         1.1.1.1/32        0          Fa0/0      23.1.1.2     
  5. 301    Untagged    2.2.2.2/32        0          Fa0/0      23.1.1.2     
  6. 302    Untagged    4.4.4.4/32        0          Fa0/1      34.1.1.4     
  7. 303    403         5.5.5.5/32        77         Fa0/1      34.1.1.4     
  8. 304    Pop tag     12.1.1.0/24       635        Fa0/0      23.1.1.2     
  9. 305    Pop tag     45.1.1.0/24       5747       Fa0/1      34.1.1.4    

看到一個奇怪的地方 了吧??爲何是POP,明明只是R3而已,應該不是次末節路由纔對。但是這個現象是什麼回事?

緣由是這樣的,咱們回過頭來看一下,咱們的BPG創建鄰居是用這樣地址來創建鄰居的:

R1:neighbor 12.1.1.1 remote-as 100

R5:neighbor 45.1.1.5 remote-as 100

對於R1來講,與45.1.1.5創建了鄰居,對於45.1.1.0這個網絡,R3就是次末節路由。因此顯示是POP。我不知道這樣講清不清楚。簡單地說,R3是45.1.1.0這個網絡的次末節路由。

那麼如何解決這個問題呢?

R1:neighbor 5.5.5.5 remote-as 100

        neighbor 5.5.5.5 update-source lo0

R5:neighbor 1.1.1.1 remote-as 100

      neighbor 1.1.1.1 update-source lo0

接下來分析另外一個問題:

  1. R2#show mpls  forwarding-table  
  2. Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop     
  3. tag    tag or VC   or Tunnel Id      switched   interface               
  4. 200    Pop tag     34.1.1.0/24       0          Fa1/0      23.1.1.3      
  5. 201    Untagged    1.1.1.1/32        0          Se0/0      point2point   
  6. 202    Untagged    3.3.3.3/32        0          Fa1/0      23.1.1.3      
  7. 203    302         4.4.4.4/32        0          Fa1/0      23.1.1.3      
  8. 204    Untagged    5.5.5.5/32        0          Fa1/0      23.1.1.3      
  9. 205    305         45.1.1.0/24       0          Fa1/0      23.1.1.3      
  10. R2# 
  1. R4#show mpls  forwarding-table  
  2. Local  Outgoing    Prefix            Bytes tag  Outgoing   Next Hop    
  3. tag    tag or VC   or Tunnel Id      switched   interface              
  4. 400    300         1.1.1.1/32        0          Fa1/0      34.1.1.3     
  5. 401    301         2.2.2.2/32        0          Fa1/0      34.1.1.3     
  6. 402    Untagged    3.3.3.3/32        0          Fa1/0      34.1.1.3     
  7. 403    Untagged    5.5.5.5/32        63         Se0/0      point2point  
  8. 404    Pop tag     23.1.1.0/24       0          Fa1/0      34.1.1.3     
  9. 405    304         12.1.1.0/24       6416       Fa1/0      34.1.1.3     

注意紅色字體的部分。untagged是什麼意思?

uptagged跟pop的一個不一樣的地方是,pop只彈出一層標籤,而untagged彈出所有標籤。

另外,在這裏顯示untagged表示,這個路由是本身發現的,而不是由鄰居告訴個人,發生一次untagged意味着這個標籤的全部標籤所有衝突。所有彈出。

看一下R4

  1. R4#show mpls  ldp  bindings 
  2.   tib entry: 1.1.1.1/32, rev 15
  3.         local binding:  tag: 402
  4.         remote binding: tsr: 3.3.3.3:0, tag: 300
  5.         remote binding: tsr: 55.5.5.5:0, tag: 503
  6.   tib entry: 2.2.2.2/32, rev 17
  7.         local binding:  tag: 403
  8.         remote binding: tsr: 3.3.3.3:0, tag: 301
  9.         remote binding: tsr: 55.5.5.5:0, tag: 504
  10.   tib entry: 3.3.3.0/24, rev 22
  11.         remote binding: tsr: 3.3.3.3:0, tag: imp-null
  12.   tib entry: 3.3.3.3/32, rev 19
  13.         local binding:  tag: 404
  14.         remote binding: tsr: 55.5.5.5:0, tag: 505
  15.   tib entry: 4.4.4.0/24, rev 5
  16.         local binding:  tag: imp-null
  17.   tib entry: 4.4.4.4/32, rev 9
  18.         remote binding: tsr: 55.5.5.5:0, tag: 500
  19.         remote binding: tsr: 3.3.3.3:0, tag: 303
  20.   tib entry: 5.5.5.0/24, rev 8
  21.         remote binding: tsr: 55.5.5.5:0, tag: imp-null
  22.   tib entry: 5.5.5.5/32, rev 11
  23.         local binding:  tag: 400
  24.         remote binding: tsr: 3.3.3.3:0, tag: 304

奇怪吧?爲何有一個是24位的,有一個是32位的?並且32位的那一條路由的下一跳是3.3.3.3????

R5:interface Loopback0

ip address 5.5.5.5 255.255.255.0

配置時是24位的。因此MPLS將它發送給R4 。

再看32位的,這是OSPF學習到的路由,OSPF認爲LOOPBACK口的都是32位的,因此R4的路由表學習到的是32位的路由,下一跳指向45.1.1.5

  1. R4#show ip route  
  2. Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
  3.        D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area 
  4.        N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
  5.        E1 - OSPF external type 1, E2 - OSPF external type 2
  6.        i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
  7.        ia - IS-IS inter area, * - candidate default, U - per-user static route
  8.        o - ODR, P - periodic downloaded static route
  9.  
  10. Gateway of last resort is not set
  11.  
  12.      34.0.0.0/24 is subnetted, 1 subnets
  13. C       34.1.1.0 is directly connected, FastEthernet1/0
  14.      1.0.0.0/24 is subnetted, 1 subnets
  15. O       1.1.1.0 [110/67] via 34.1.1.3, 00:09:54, FastEthernet1/0
  16.      2.0.0.0/24 is subnetted, 1 subnets
  17. O       2.2.2.0 [110/3] via 34.1.1.3, 00:09:54, FastEthernet1/0
  18.      3.0.0.0/24 is subnetted, 1 subnets
  19. O       3.3.3.0 [110/2] via 34.1.1.3, 00:09:54, FastEthernet1/0
  20.      4.0.0.0/24 is subnetted, 1 subnets
  21. C       4.4.4.0 is directly connected, Loopback0
  22.      5.0.0.0/32 is subnetted, 1 subnets
  23. O       5.5.5.5 [110/65] via 45.1.1.5, 00:09:54, Serial0/0
  24.      23.0.0.0/24 is subnetted, 1 subnets
  25. O       23.1.1.0 [110/2] via 34.1.1.3, 00:09:56, FastEthernet1/0
  26.      12.0.0.0/24 is subnetted, 1 subnets
  27. O       12.1.1.0 [110/66] via 34.1.1.3, 00:09:56, FastEthernet1/0
  28.      45.0.0.0/24 is subnetted, 1 subnets
  29. C       45.1.1.0 is directly connected, Serial0/0
  1. tib entry: 5.5.5.0/24, rev 8
  2.         remote binding: tsr: 55.5.5.5:0, tag: imp-null
  3. 這是R5發送給R4 的,可是R4自己沒有這條路由,因此自己沒有給 這條路由分配標籤。
  1. tib entry: 5.5.5.5/32, rev 11
  2.         local binding:  tag: 400
  3.         remote binding: tsr: 3.3.3.3:0, tag: 304
  4. 這是R3分發給R4的,由於R4自己也有這條5.5.5.5/32的路由,因此自己也會爲這條路由分發標籤。

5.5.5.5/32這條路由的下一跳是45.1.1.5,而標籤表中:

  1. tib entry: 5.5.5.5/32, rev 11
  2.         local binding:  tag: 400
  3.         remote binding: tsr: 3.3.3.3:0, tag: 304

下一跳是3.3.3.3,這是矛盾的。因此這一標籤不可用。

可是對於5.5.5.5/32這條路由,R4認爲R5沒有給本身這條路由,因此就untagged  了。

雖然這不影響整個網張的連通,你能夠試一下,能夠ping通整個網絡。

可是顯然影響到標籤的連續性。MPLS網絡最重要的是就標籤的連續性問題,標籤分配的不合理,生期可能會很麻煩。

因此這個問題是必須解決的。解決方法很簡單,就是在每一個路由器每一個loopback 口啓用:

ip ospf network point-to-point

這樣就能夠了。

這篇文章就到此爲止了。不知道邏輯有沒有混亂。若是有讀者看了的話,以爲很混亂的,能夠批評。

相關文章
相關標籤/搜索