Cisco
跨域三層××× OptionC配置指導
1 OptionC方式跨域×××的理解
以前,我寫了一篇OptionB的文檔,並提供了相應的配置,對於該文檔中相應的內容,我在這裏就再也不羅嗦了,本文開始對OptionC方式的跨域×××作分析。
在OptionB方式中,×××的路由信息是經過自治系統之間的ASBR來保存和擴散的,當×××路由比較多的時候,會對ASBR產生巨大的壓力;若是通過多個自治系統,每一個ASBR上都會維護大量相同的×××路由,因爲這些ASBR通常都承擔着公網IP轉發的任務,這樣對設備的要求就更高了。從另外一個方面來看,OptionB方式採用的是一種中繼的方式,經過ASBR把×××路由信息向其餘自治系統擴散,這也把這些中間設備強加上必需要支持×××功能的要求,雖然對於設備而言,這是必須的,可是這樣的實現方式我的以爲並不徹底符合三層×××的思想,按照正常的理解,除了接入CE的PE以外,其餘設備是不該該看到×××信息的,這也是OptionC方式所解決的問題。
OptionC方式的思想就是在跨域的狀況下,PE之間仍然能夠像域內那樣,在PE和PE之間創建直接的MEBGP鄰居,交換×××V4路由信息,這樣就不須要中間設備再保存、維護和擴散×××路由信息。這裏須要從兩個方面去考慮:信令和轉發。在信令層面上,實現跨域MEBGP鄰居的創建,並交換×××路由信息並非一件困難的事情,只要公網路由可達,創建起鄰居,私網的×××路由信息就能夠很輕鬆的發給對端鄰居了。可是,在轉發層面上,還有一個最重要的問題須要解決,那就是如何在跨域的狀況下創建一條PE到PE的××× LSP,不然,即使有了×××路由信息,到了公網部分,根本沒法識別數據的私網標籤,轉發層面上仍是不通的。
這裏,須要提到標籤IPv4路由,在RFC3107即[Carrying Label Information in BGP-4]中有定義。這裏在ASBR之間傳遞的就不是普通的IP路由信息了,而是攜帶了標籤的公網路由信息,這樣,就會在公網上造成一個由BGP觸發的公網LSP,在公網上也是靠標籤交換就數據傳送到目的地,而公網上沒法識別的私網標籤就能夠被封裝在內層做爲內層標籤被轉發了。有興趣的朋友能夠看一下RFC3107中所定義的應用場景和具體的update的消息格式,該RFC內容不長,這裏不做過多的闡述,下面列舉一下普通的update和支持標籤IPv4路由信息的update的格式便可。
普通update消息
標籤ipv4格式的update消息
2 OptionC方式的數據轉發
仍然沿用跟OptionB方式中大體相似的網絡結構,如上圖。
以從R6上的vrf30 ping R1上的vrf30爲例,即ping vrf vrf30
10.0.30
.1 source 60.0.30.1,從R6àR1方向,IP數據會首先被封裝上×××v4目的路由對應的標籤,接着會被封裝上標籤IPv4路由信息對應的標籤,最後纔會被封裝上LDP標籤,其中LDP標籤完成LDP域的標籤交換,隨後經過標籤IPv4路由的標籤完成EBGP域的標籤交換,而後再進入對方自治系統的LDP域,最後經過私網標籤完成×××域的標籤交換,達到目的地。也就是說在整個數據傳輸過程當中,最多的時候數據會被封裝三層標籤,即LDP | EBGP標籤 | 私網標籤。在上面的拓撲中,可以看到三層標籤的位置爲R6到R5的出方向,理論上LDP域中都應該是三層標籤頭,可是因爲存在空標籤的緣故,有的位置只能顯示的看到兩層標籤。在R5和R6之間抓包以下,能夠清楚的看到三層標籤:
在R6上顯示各類標籤信息,能夠明顯的看出圖中的標籤16爲LDP標籤,標籤29爲EBGP公網標籤,標籤18爲私網路由標籤,顯示信息以下:
私網路由標籤
R6#show bgp ***v4 unicast all labels
Network Next Hop In label/Out label
Route Distinguisher: 100:20 (vrf20)
10.0.30
.0/24 202.1.1.1 nolabel/17
60.0.20.0/24
0.0.0
.0 19/aggregate(vrf20)
Route Distinguisher: 100:30 (vrf30)
10.0.30
.0/24 202.1.1.1 nolabel/18
60.0.30.0/24
0.0.0
.0 20/aggregate(vrf30)
公網EBGP標籤
R6#show bgp ipv4 unicast labels
Network Next Hop In Label/Out Label
80.1.2.0/24 202.1.1.4 nolabel/25
80.2.3.0/24 202.1.1.4 nolabel/26
80.2.3.2/32 202.1.1.4 nolabel/28
80.5.6.0/24
0.0.0
.0 imp-null/nolabel
202.1.1.1/32 202.1.1.4 nolabel/29
202.1.1.2/32 202.1.1.4 nolabel/27
202.1.1.6/32
0.0.0
.0 imp-null/nolabel
LDP標籤
R6#show mpls forwarding-table
Local Outgoing Prefix Bytes tag Outgoing Next Hop
tag tag or VC or Tunnel Id switched interface
16 Pop tag 80.4.5.0/24 0 Et4/0 80.5.6.1
17 16 202.1.1.4/32 0 Et4/0 80.5.6.1
18 Pop tag 202.1.1.5/32 0 Et4/0 80.5.6.1
19 Aggregate 60.0.20.0/24[V] 0
20 Aggregate 60.0.30.0/24[V] 0
從上面的顯示信息也能夠清楚的看出路由的迭代關係與標籤之間的關聯,即到vrf30
10.0.30
.0/24的下一跳爲202.1.1.1,到202.1.1.1的下一跳爲202.1.1.4,經過路由迭代造成一個三層標籤16 | 29 | 18 ,與抓包的數據徹底一致。
3 OptionC方式的關鍵點
BGP4的擴展:
經過RFC3107對BGP4進行擴展,使得BGP發佈路由信息時能夠支持標籤IPv4路由信息,因此在配置的時候也要配置支持標籤IPv4路由信息的能力,若是不進行配置,那麼只是普通的BGP,發佈的路由信息也是普通的IPv4路由。
路由策略的建立:
在ASBR上應用路由策略,對於從本AS的PE接收的路由,在向對端ASBR發佈時,分配MPLS 標籤。對於向本AS的PE 發佈的路由,若是是帶標籤的IPv4路由,爲其從新分配MPLS 標籤。對IPv4 路由分配MPLS標籤是經過路由策略控制的,只對知足某些條件的路由分配標籤,其它路由仍是普通IPv4 路由。缺省狀況下,IPv4 路由不帶MPLS 標籤。
4 數據設計
因爲通常的跨域×××配置示例都是兩個AS,這裏我故意調整成了三個AS,其實也沒什麼變化,就是多配置一些EBGP鄰居而已。
Loopback地址:202.1.1.X/32,X=1、2、3、4、5、6,即路由器序號;
接口地址:80.X.Y.Z/24,X/Y=路由器序號,Z=1、2,路由器序號小的爲1,大的爲2;
IGP:PE-P-PE之間部署OSPF和LDP,ASBR之間不起用任何IGP,只創建MEBGP鄰居;
AS:R1和R2AS號爲200,R3的AS號爲300,R4和R6的AS號爲400;
Vrf:R1上配置兩個vrf
Vrf20 RD=100:20 RT=100:20 路由爲
10.0.30
.0/24
Vrf30 RD=100:30 RT=100:30 路由爲
10.0.30
.0/24
配置爲不一樣***相同的路由是客觀驗證一下***路由地址重疊的狀況。
R6上配置兩個vrf
Vrf20 RD=100:20 RT=100:20 路由爲60.0.20.0/24
Vrf30 RD=100:30 RT=100:30 路由爲60.0.30.0/24
5 詳細配置
爲了節約版本,只羅列出6臺路由器的相關配置,其餘無關配置均不貼出來。具體的配置和顯示信息能夠參看最後附件中的文檔。
[R1]
R1#show run
!
version 12.4
!
hostname R1
!
ip cef
!
ip vrf vrf10
rd 100:10
route-target export 100:10
route-target import 100:10
!
ip vrf vrf20
rd 100:20
route-target export 100:20
route-target import 100:20
!
ip vrf vrf30
rd 100:30
route-target export 100:30
route-target import 100:30
!
interface Loopback0
ip address 202.1.1.1 255.255.255.255
!
interface Ethernet4/0
ip address 80.1.2.1 255.255.255.0
duplex full
mpls ip
!
interface Ethernet4/6
ip vrf forwarding vrf20
ip address
10.0.30
.1 255.255.255.0
duplex half
!
interface Ethernet4/7
ip vrf forwarding vrf30
ip address
10.0.30
.1 255.255.255.0
duplex half
!
router ospf 1
log-adjacency-changes
network 80.1.2.0
0.0.0
.255 area 0
network 202.1.1.1
0.0.0
.0 area 0
!
router bgp 200
bgp log-neighbor-changes
neighbor 202.1.1.2 remote-as 200
neighbor 202.1.1.2 update-source Loopback0
neighbor 202.1.1.6 remote-as 400
neighbor 202.1.1.6 ebgp-multihop 10
neighbor 202.1.1.6 update-source Loopback0
!
address-family ipv4
redistribute connected
neighbor 202.1.1.2 activate
neighbor 202.1.1.2 send-label
no neighbor 202.1.1.6 activate
no auto-summary
no synchronization
exit-address-family
!
address-family ***v4
neighbor 202.1.1.6 activate
neighbor 202.1.1.6 send-community extended
exit-address-family
!
address-family ipv4 vrf vrf30
redistribute connected
no synchronization
exit-address-family
!
address-family ipv4 vrf vrf20
redistribute connected
no synchronization
exit-address-family
!
address-family ipv4 vrf vrf10
no synchronization
exit-address-family
!
end
[R2]
R2#show run
!
version 12.4
!
hostname R2
!
ip cef
!
interface Loopback0
ip address 202.1.1.2 255.255.255.255
!
interface Ethernet4/0
ip address 80.1.2.2 255.255.255.0
duplex full
mpls ip
!
interface Ethernet4/1
ip address 80.2.3.1 255.255.255.0
duplex full
!
router ospf 1
log-adjacency-changes
network 80.1.2.0
0.0.0
.255 area 0
network 202.1.1.2
0.0.0
.0 area 0
!
router bgp 200
no synchronization
no bgp default route-target filter
bgp log-neighbor-changes
redistribute connected
redistribute ospf 1
neighbor 80.2.3.2 remote-as 300
neighbor 80.2.3.2 route-map atol out
neighbor 80.2.3.2 send-label
neighbor 202.1.1.1 remote-as 200
neighbor 202.1.1.1 update-source Loopback0
neighbor 202.1.1.1 next-hop-self
neighbor 202.1.1.1 route-map ltol out
neighbor 202.1.1.1 send-label
no auto-summary
!
route-map atol permit 10
set mpls-label
!
route-map ltol permit 10
match mpls-label
set mpls-label
end
[R3]
R3#show run
!
version 12.4
!
hostname R3
!
ip cef
!
interface Loopback0
ip address 202.1.1.3 255.255.255.255
!
interface Ethernet4/1
ip address 80.2.3.2 255.255.255.0
duplex full
!
interface Ethernet4/2
ip address 80.3.4.1 255.255.255.0
duplex half
!
router bgp 300
no synchronization
no bgp default route-target filter
bgp log-neighbor-changes
neighbor 80.2.3.1 remote-as 200
neighbor 80.2.3.1 route-map atol out
neighbor 80.2.3.1 send-label
neighbor 80.3.4.2 remote-as 400
neighbor 80.3.4.2 route-map atol out
neighbor 80.3.4.2 send-label
no auto-summary
!
route-map atol permit 10
set mpls-label
!
end
[R4]
R4#show run
!
version 12.4
!
hostname R4
!
ip cef
!
interface Loopback0
ip address 202.1.1.4 255.255.255.255
!
interface Ethernet4/2
ip address 80.3.4.2 255.255.255.0
duplex half
!
interface Ethernet4/3
ip address 80.4.5.1 255.255.255.0
duplex half
mpls ip
!
router ospf 1
log-adjacency-changes
network 80.4.5.0
0.0.0
.255 area 0
network 202.1.1.4
0.0.0
.0 area 0
!
router bgp 400
no synchronization
no bgp default route-target filter
bgp log-neighbor-changes
redistribute connected
redistribute ospf 1
neighbor 80.3.4.1 remote-as 300
neighbor 80.3.4.1 route-map atol out
neighbor 80.3.4.1 send-label
neighbor 202.1.1.6 remote-as 400
neighbor 202.1.1.6 update-source Loopback0
neighbor 202.1.1.6 next-hop-self
neighbor 202.1.1.6 route-map ltol out
neighbor 202.1.1.6 send-label
no auto-summary
!
route-map atol permit 10
set mpls-label
!
route-map ltol permit 10
match mpls-label
set mpls-label
!
end
[R5]
R5#show run
!
version 12.4
!
hostname R5
!
ip cef
!
interface Loopback0
ip address 202.1.1.5 255.255.255.255
!
interface Ethernet4/0
ip address 80.5.6.1 255.255.255.0
duplex half
mpls ip
!
interface Ethernet4/3
ip address 80.4.5.2 255.255.255.0
duplex half
mpls ip
!
router ospf 1
log-adjacency-changes
network 80.4.5.0
0.0.0
.255 area 0
network 80.5.6.0
0.0.0
.255 area 0
network 202.1.1.5
0.0.0
.0 area 0
!
end
[R6]
R6#show run
!
version 12.4
!
hostname R6
!
ip cef
!
ip vrf vrf10
rd 100:10
route-target export 100:10
route-target import 100:10
!
ip vrf vrf20
rd 100:20
route-target export 100:20
route-target import 100:20
!
ip vrf vrf30
rd 100:30
route-target export 100:30
route-target import 100:30
!
interface Loopback0
ip address 202.1.1.6 255.255.255.255
!
interface FastEthernet0/0
no ip address
shutdown
duplex half
!
interface Ethernet4/0
ip address 80.5.6.2 255.255.255.0
duplex half
mpls ip
!
interface Ethernet4/6
ip vrf forwarding vrf20
ip address 60.0.20.1 255.255.255.0
duplex half
!
interface Ethernet4/7
ip vrf forwarding vrf30
ip address 60.0.30.1 255.255.255.0
duplex half
!
router ospf 1
log-adjacency-changes
network 80.5.6.0
0.0.0
.255 area 0
network 202.1.1.6
0.0.0
.0 area 0
!
router bgp 400
bgp log-neighbor-changes
neighbor 202.1.1.1 remote-as 200
neighbor 202.1.1.1 ebgp-multihop 10
neighbor 202.1.1.1 update-source Loopback0
neighbor 202.1.1.4 remote-as 400
neighbor 202.1.1.4 update-source Loopback0
!
address-family ipv4
redistribute connected
no neighbor 202.1.1.1 activate
neighbor 202.1.1.4 activate
neighbor 202.1.1.4 send-label
no auto-summary
no synchronization
exit-address-family
!
address-family ***v4
neighbor 202.1.1.1 activate
neighbor 202.1.1.1 send-community extended
exit-address-family
!
address-family ipv4 vrf vrf30
redistribute connected
no synchronization
exit-address-family
!
address-family ipv4 vrf vrf20
redistribute connected
no synchronization
exit-address-family
!
address-family ipv4 vrf vrf10
redistribute connected
no synchronization
exit-address-family
!
end
根據朋友的提醒,在此增長從R6到R1的私網路由trace信息,能夠清楚的看到沿途標籤信息的變化:
R6#traceroute vrf vrf30
Protocol [ip]:
Target IP address: 10.0.30.1
Source address: 60.0.30.1
Numeric display [n]:
Resolve AS number in (G)lobal table, (V)RF or(N)one [G]:
Timeout in seconds [3]:
Probe count [3]:
Minimum Time to Live [1]:
Maximum Time to Live [30]:
Port Number [33434]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Type escape sequence to abort.
Tracing the route to 10.0.30.1
1 80.5.6.1 [MPLS: Labels 16/20/18 Exp 0] 300 msec 456 msec 384 msec 2 80.4.5.1 [MPLS: Labels 20/18 Exp 0] 320 msec 336 msec 312 msec 3 80.3.4.1 [MPLS: Labels 24/18 Exp 0] 280 msec 280 msec 328 msec 4 80.2.3.1 [AS 200] [MPLS: Labels 17/18 Exp 0] 300 msec 264 msec 480 msec 5 10.0.30.1 376 msec 388 msec 580 msec