想了好久才決定要寫這篇文章。由於我感受有好多能夠說,而且要寫出博文有點困難。仍是盡力吧,不寫出來可能也很快就忘了。網絡
按照個人習慣是先上拓撲:dom
![](http://static.javashuo.com/static/loading.gif)
這就是個人拓撲。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 這條命令也很重要。 下面這一段講解這一條命令的做用:、
- no mpls ip propagate-ttl forwarded
- 這條命令的意思是,不看IP包的TTL值,由於在PE上,MPLS會copy IP包中的TTL值填充MPLS包頭
- 中的TTL字段。
- 例如當一個數據包進入MPLS網絡時,也就是剛進入PE。
- 假設IP包中的TTL值=6,這時PE先減去1 ,TTL=6-1=5。而後將TTL填充進MPLS包頭的TTL,所
- 以這時MPLS包頭的TTL值就是5。
- 以後在MPLS網絡中傳輸時,由於在MPLS網絡中是不看IP包頭的,因此IP包頭的TTL值不會減小,但
- 是MPLS的TTL值每通過一個路由器就減小1,(當減小爲0時丟棄。其實當路由器收到一個TTL=1的
- 包時就要丟棄了。)最後,在鏈接目的網絡的PE上面,MPLS包頭的TTL值先減去1 ,以後再copy
- 回去覆蓋了IP包頭的TTL字段。這樣子的話,在外部網絡的用戶就能夠tracert MPLS網絡,得知
- MPLS網絡的結構。
- 因此咱們須要這條no mpls ip propagate-ttl forwarded 命令,不要從IP包中複製TTL值,
- 直接填充MPLS的TTL=255.
- Traceroute就是利用TTL的技術來實現的,第一次發包TTL是1,包到達下一跳後,TTL變成0,包
- 被丟棄,並響應一個TTL超時。而後,依次遞增TTL,依次響應TTL超時,就能發現路徑了。若是ISP
- 網絡沒有禁用TTL,那麼客戶就能夠利用Traceroute探查到ISP的內部路由了,啓用以下命令,防止
- 該事情發生。
- forwarded是指NO掉CE過來的TTL值,local是指本身的也要NO掉,通常在邊界路由器打上
- forwarded就好,保證本身仍是能夠traceroute的,默認不打,兩個所有NO掉。
- 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
- 這條命令的做用是用接口的地址與鄰居創建LDP關係。使用直鏈接口地址可保證下 一跳可達。
- 創建以後在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最難的是跟蹤標籤。下面咱們就來跟蹤一下標籤。
- R1#show mpls forwarding-table
- Local Outgoing Prefix Bytes tag Outgoing Next Hop
- tag tag or VC or Tunnel Id switched interface
- 100 200 34.1.1.0/24 0 Se0/0 point2point
- 101 Untagged 2.2.2.2/32 0 Se0/0 point2point
- 102 202 3.3.3.3/32 0 Se0/0 point2point
- 103 203 4.4.4.4/32 0 Se0/0 point2point
- 104 204 5.5.5.5/32 0 Se0/0 point2point
- 105 Pop tag 23.1.1.0/24 0 Se0/0 point2point
- 106 205 45.1.1.0/24 0 Se0/0 point2point
- R2#show mpls forwarding-table
- Local Outgoing Prefix Bytes tag Outgoing Next Hop
- tag tag or VC or Tunnel Id switched interface
- 200 Pop tag 34.1.1.0/24 0 Fa1/0 23.1.1.3
- 201 Untagged 1.1.1.1/32 0 Se0/0 point2point
- 202 Untagged 3.3.3.3/32 0 Fa1/0 23.1.1.3
- 203 302 4.4.4.4/32 0 Fa1/0 23.1.1.3
- 204 Untagged 5.5.5.5/32 0 Fa1/0 23.1.1.3
- 205 305 45.1.1.0/24 0 Fa1/0 23.1.1.3
- R2#
- R3#show mpls for
- Local Outgoing Prefix Bytes tag Outgoing Next Hop
- tag tag or VC or Tunnel Id switched interface
- 300 201 1.1.1.1/32 0 Fa0/0 23.1.1.2
- 301 Untagged 2.2.2.2/32 0 Fa0/0 23.1.1.2
- 302 Untagged 4.4.4.4/32 0 Fa0/1 34.1.1.4
- 303 403 5.5.5.5/32 77 Fa0/1 34.1.1.4
- 304 Pop tag 12.1.1.0/24 635 Fa0/0 23.1.1.2
- 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
接下來分析另外一個問題:
- R2#show mpls forwarding-table
- Local Outgoing Prefix Bytes tag Outgoing Next Hop
- tag tag or VC or Tunnel Id switched interface
- 200 Pop tag 34.1.1.0/24 0 Fa1/0 23.1.1.3
- 201 Untagged 1.1.1.1/32 0 Se0/0 point2point
- 202 Untagged 3.3.3.3/32 0 Fa1/0 23.1.1.3
- 203 302 4.4.4.4/32 0 Fa1/0 23.1.1.3
- 204 Untagged 5.5.5.5/32 0 Fa1/0 23.1.1.3
- 205 305 45.1.1.0/24 0 Fa1/0 23.1.1.3
- R2#
- R4#show mpls forwarding-table
- Local Outgoing Prefix Bytes tag Outgoing Next Hop
- tag tag or VC or Tunnel Id switched interface
- 400 300 1.1.1.1/32 0 Fa1/0 34.1.1.3
- 401 301 2.2.2.2/32 0 Fa1/0 34.1.1.3
- 402 Untagged 3.3.3.3/32 0 Fa1/0 34.1.1.3
- 403 Untagged 5.5.5.5/32 63 Se0/0 point2point
- 404 Pop tag 23.1.1.0/24 0 Fa1/0 34.1.1.3
- 405 304 12.1.1.0/24 6416 Fa1/0 34.1.1.3
注意紅色字體的部分。untagged是什麼意思?
uptagged跟pop的一個不一樣的地方是,pop只彈出一層標籤,而untagged彈出所有標籤。
另外,在這裏顯示untagged表示,這個路由是本身發現的,而不是由鄰居告訴個人,發生一次untagged意味着這個標籤的全部標籤所有衝突。所有彈出。
看一下R4
- R4#show mpls ldp bindings
- tib entry: 1.1.1.1/32, rev 15
- local binding: tag: 402
- remote binding: tsr: 3.3.3.3:0, tag: 300
- remote binding: tsr: 55.5.5.5:0, tag: 503
- tib entry: 2.2.2.2/32, rev 17
- local binding: tag: 403
- remote binding: tsr: 3.3.3.3:0, tag: 301
- remote binding: tsr: 55.5.5.5:0, tag: 504
- tib entry: 3.3.3.0/24, rev 22
- remote binding: tsr: 3.3.3.3:0, tag: imp-null
- tib entry: 3.3.3.3/32, rev 19
- local binding: tag: 404
- remote binding: tsr: 55.5.5.5:0, tag: 505
- tib entry: 4.4.4.0/24, rev 5
- local binding: tag: imp-null
- tib entry: 4.4.4.4/32, rev 9
- remote binding: tsr: 55.5.5.5:0, tag: 500
- remote binding: tsr: 3.3.3.3:0, tag: 303
- tib entry: 5.5.5.0/24, rev 8
- remote binding: tsr: 55.5.5.5:0, tag: imp-null
- tib entry: 5.5.5.5/32, rev 11
- local binding: tag: 400
- 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
- R4#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, FastEthernet1/0
- 1.0.0.0/24 is subnetted, 1 subnets
- O 1.1.1.0 [110/67] via 34.1.1.3, 00:09:54, FastEthernet1/0
- 2.0.0.0/24 is subnetted, 1 subnets
- O 2.2.2.0 [110/3] via 34.1.1.3, 00:09:54, FastEthernet1/0
- 3.0.0.0/24 is subnetted, 1 subnets
- O 3.3.3.0 [110/2] via 34.1.1.3, 00:09:54, FastEthernet1/0
- 4.0.0.0/24 is subnetted, 1 subnets
- C 4.4.4.0 is directly connected, Loopback0
- 5.0.0.0/32 is subnetted, 1 subnets
- O 5.5.5.5 [110/65] via 45.1.1.5, 00:09:54, Serial0/0
- 23.0.0.0/24 is subnetted, 1 subnets
- O 23.1.1.0 [110/2] via 34.1.1.3, 00:09:56, FastEthernet1/0
- 12.0.0.0/24 is subnetted, 1 subnets
- O 12.1.1.0 [110/66] via 34.1.1.3, 00:09:56, FastEthernet1/0
- 45.0.0.0/24 is subnetted, 1 subnets
- C 45.1.1.0 is directly connected, Serial0/0
- tib entry: 5.5.5.0/24, rev 8
- remote binding: tsr: 55.5.5.5:0, tag: imp-null
- 這是R5發送給R4 的,可是R4自己沒有這條路由,因此自己沒有給 這條路由分配標籤。
- tib entry: 5.5.5.5/32, rev 11
- local binding: tag: 400
- remote binding: tsr: 3.3.3.3:0, tag: 304
- 這是R3分發給R4的,由於R4自己也有這條5.5.5.5/32的路由,因此自己也會爲這條路由分發標籤。
5.5.5.5/32這條路由的下一跳是45.1.1.5,而標籤表中:
- tib entry: 5.5.5.5/32, rev 11
- local binding: tag: 400
- 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
這樣就能夠了。
這篇文章就到此爲止了。不知道邏輯有沒有混亂。若是有讀者看了的話,以爲很混亂的,能夠批評。