論MPLS VPN網絡 VRF、RT與RD的作用,附帶實例


  • VRF(Virtual Route Forwarding): VRF的目的是解決不同企業私網地址段相同,為了防止衝突,採用將相同私網地址放到不同的VRF表中。VRF區分不同CE端進來邊界PE的相同私網路由,路由器的每一個VRF 都自動生成相應VRF表,比如show route vrf A ,show route vrf B。對於每一個VRF表,都具有路由區分符(Route Distinguisher:RD)和路由目標(Route Target:RT)兩大屬性。
  • RD(Route-Distinguisher): 8個字節的RD+4個字節的IPv4地址組成96位VPNv4路由,使不唯一的IPv4地址轉化為唯一的VPN-IPv4地址,該VPNv4路由在ISP域內傳遞(區分),RD給某VRF裡面的路由打上標籤,進而實現地址的複用而不產生衝突。RD用來區分本地VRF,該屬性僅本地有效。
  • RT(Route Tagert):BGP的擴展團體屬性,它分成Import RT和Export RT,分別用於路由的導入、導出策略。也即RT是控制這個VRF裡面可以發出和接受什麼樣的路由。RT具有全局唯一性,並且只能被一個VPN使用。
  • 關於RT,新人還要注意的點:

當從VRF表中導出VPN路由給BGP鄰居時,要用Export RT對VPN路由進行標記;在往BGP鄰居的VRF表中導入VPN路由時,只有所帶RT標記與VRF表中任意一個Import RT相符的路由才會被導入到VRF表中。RT使得PE路由器只包含和其直接相連的VPN的路由,而不是全網所有VPN的路由,從而節省了PE路由器的資源,提高了網絡拓展性。(將connect路由發給BGP鄰居,而)

通過配置import和export RT,來控制收發路由。

1.當從VRF表中導出VPN路由時,要用Export RT對VPN路由進行標記。

2.當往VRF表中導入VPN路由時,只有所帶RT標記與VRF表中任意一個Import RT相符的路由才會被導入到VRF表中。

舉個例子:


論MPLS VPN網絡 VRF、RT與RD的作用,附帶實例

CE-A對應21-PE的接口加入到vrf A,CE-B對應05-PE的接口加入到vrf B

  • 運營商網絡一般至少部署雙RR冗餘,也即PE只是和RR建立MP-BGP鄰居。
  • MPLS內啟用IGP(一般用isis動態路由協議)給建立ibgp鄰居提供路由可達(TCP連接建立條件)、MPLS內啟用MPLS,確保MPLS鄰居UP。
  • PE和RR只跑信令,此流量很小的,數據轉發還是靠PE去完成。
<code>RP/0/RSP1/CPU0:D-21-PE-A-ASR9010-new#show running-config vrf A
Sat Mar 21 20:34:35.091 BeiJing
vrf A
address-family ipv4 unicast
import route-target
64512:510 #vrf A 的RD值
33580:1
!
export route-target
64512:510
!
!
!
21-PE有些直連路由:
D-21-PE-A-ASR9010-new#show route vrf B connected
C 10.32.91.0/30 is directly connected, 48w2d, Bundle-Ether109.1924
C 10.32.91.4/30 is directly connected, 48w2d, Bundle-Ether109.1881
C 10.32.91.8/29 is directly connected, 1y18w, Bundle-Ether109.1966

RP/0/RSP0/CPU0:D-05-PE-A-ASR9010#show running-config vrf B
Sat Mar 21 20:43:06.136 BeiJing
vrf GOV_HZSQHDJK
address-family ipv4 unicast
import route-target

33580:1 #B 的RD值
64512:510
!
export route-target
33580:1
!
!
!
RP/0/RSP0/CPU0:D-05-PE-A-ASR9010#show route vrf B connected
C 10.6.21.16/30 is directly connected, 1y22w, Bundle-Ether105.136
C 10.6.21.44/30 is directly connected, 1y26w, Bundle-Ether105.1032
因為兩PE互相import了彼此的RT,故05-PE及21-PE上存在彼此VRF的路由:
D-05-PE-A-ASR9010#show route vrf B 10.32.91.0
Sat Mar 21 20:47:24.926 BeiJing
Routing entry for 10.32.91.0/30
Known via "bgp 64512", distance 200, metric 0, type internal
Installed Apr 18 01:21:40.276 for 48w2d
Routing Descriptor Blocks
172.25.8.17, from 172.25.8.110
Nexthop in Vrf: "default", Table: "default", IPv4 Unicast, Table Id: 0xe0000000
Route metric is 0
No advertising protos.
RP/0/RSP1/CPU0:D-21-PE-A-ASR9010-new#show route vrf A 10.6.21.16
Known via "bgp 64512", distance 200, metric 0, type internal
Installed Mar 25 23:52:54.334 for 51w4d
Routing Descriptor Blocks
172.25.8.5, from 172.25.8.110
Nexthop in Vrf: "default", Table: "default", IPv4 Unicast, Table Id: 0xe0000000
Route metric is 0
No advertising protos. /<code>

可以看到兩PE學習到vrf的路由情況:

<code>因為兩PE互相import了彼此的RT,故05-PE及21-PE上存在彼此VRF的路由:
RP/0/RSP0/CPU0:D-05-PE-A-ASR9010#show route vrf B 10.32.91.0
Sat Mar 21 20:47:24.926 BeiJing
Routing entry for 10.32.91.0/30
Known via "bgp 64512", distance 200, metric 0, type internal
Installed Apr 18 01:21:40.276 for 48w2d
Routing Descriptor Blocks
172.25.8.17, from 172.25.8.110
Nexthop in Vrf: "default", Table: "default", IPv4 Unicast, Table Id: 0xe0000000
Route metric is 0
No advertising protos.
RP/0/RSP1/CPU0:D-21-PE-A-ASR9010-new#show route vrf A 10.6.21.16

Known via "bgp 64512", distance 200, metric 0, type internal
Installed Mar 25 23:52:54.334 for 51w4d
Routing Descriptor Blocks
172.25.8.5, from 172.25.8.110
Nexthop in Vrf: "default", Table: "default", IPv4 Unicast, Table Id: 0xe0000000
Route metric is 0
No advertising protos. /<code>

根據如下配置提個問題:

<code>D-21-PE-A-ASR9010-new#show running-config vrf C
vrf C
address-family ipv4 unicast
import route-target
10006:114 #vrf C的RD
64512:510
!
export route-target
10006:114
!
!
!
D-05-PE-A-ASR9010-new#show running-config vrf D
vrf D
address-family ipv4 unicast
import route-target
33580:1 #vrf D的RD
64512:510
!
export route-target
33580:1
64512:510 #沒有export 64512:510 和 export 64512:510
!
!
!/<code>

問題:vrf D沒有export 64512:510 和有export 64512:510 C是否會有D的路由?(答案見評論處),D是否有C的路由?

總結:

<code>vrf F
address-family ipv4 unicast
import route-target
10000:146

10000:160
10006:114
10051:115
!
export route-target#其他鄰居PE想要學習到中心點的路由,只需要import了【1000:146 | 10000:160|10006:114|10051:115】 都將收到的VRF F的路由加載到相應的VRF表中。
10000:146
10000:160
10006:114
10051:115
!
!
!
有來的路由還得有回去的,import 【10000:146|10000:160|10006:114|10051:115】將 攜帶export 這相同RT的路由條目加載到VRF F表中。
這樣實現相應vrf 路由在兩PE之間可達。/<code>

大家都理解了嗎?有不理解的可在下方留言(需要持續交流的可加關注)。


分享到:


相關文章: