簡介
本檔案將介紹PfRv2(效能路由)如何根據PfRv2策略決策控制流量。本文討論在PfRv2中使用靜態路由和基於策略的路由。
必要條件
需求
思科建議您瞭解效能路由(PfR)的基本知識。
採用元件
本文件所述內容不限於特定軟體和硬體版本。
本文中的資訊是根據特定實驗室環境內的裝置所建立。文中使用到的所有裝置皆從已清除(預設)的組態來啟動。如果您的網路正在作用,請確保您已瞭解任何指令可能造成的影響。
設定
PfRv2允許網路管理員根據PfRv2策略結果配置策略並相應地路由流量。PfRv2控制流量的模式多種多樣,這取決於獲知目的地首碼的父路由所使用的協定。PfRv2能夠通過操縱路由協定、注入靜態路由或通過基於動態策略的路由來更改路由資訊庫(RIB)。
- 如果父路由是通過BGP獲知的,PfRv2可以使用本地優先順序等屬性動態操作路由。
- 如果父路由是通過EIGRP獲取的,PfRv2可以在EIGRP拓撲表中插入新路由。
- 如果父路由是通過靜態路由獲知的,則PfR2會在PfR選定的邊界路由器(BR)上注入更具體(更好)的路由。
- 如果父路由通過上述三種機制中的任何一種得知,則PfRv2使用基於策略的路由(PBR)將流量推送到所選BR上。
本文討論PfRv2使用靜態路由(當父路由通過靜態路由時)和PBR(當RIB中的父路由通過RIP、OSPF、ISIS等時)來控制流量。
網路圖表
本文檔將以下影象作為本文檔其餘部分的示例拓撲。
圖中所示的裝置:
R1 — 伺服器,正在發起流量。
R3- PfR主路由器。
R4和R5- PfR邊界路由器。
連線到R9和R10的客戶端是從R1伺服器接收流量的裝置。
組態
在此案例中,將配置兩個學習清單,一個用於應用(APPLICATION-LEARN-LIST)和資料(DATA-LEARN-LIST)流量。此案例使用字首清單來定義流量。訪問清單還可用於匹配TCP、UDP、ICMP等流量型別。DSCP和TOS也可用於定義流量。
key chain pfr
key 0
key-string cisco
pfr master
policy-rules PFR
!
border 10.4.4.4 key-chain pfr
interface Tunnel0 internal
interface Ethernet1/0 external
interface Ethernet1/2 internal
link-group MPLS
!
border 10.5.5.5 key-chain pfr
interface Tunnel0 internal
interface Ethernet1/3 internal
interface Ethernet1/0 external
link-group INET
!
learn
traffic-class filter access-list DENY-ALL
list seq 10 refname APPLICATION-LEARN-LIST //Learn-list for application traffic
traffic-class prefix-list APPLICATION
throughput
list seq 20 refname DATA-LEARN-LIST //Learn-list for data traffic
traffic-class prefix-list DATA
throughput
!
!
pfr-map PFR 10
match pfr learn list APPLICATION-LEARN-LIST
set periodic 90
set delay threshold 25
set mode monitor active
set active-probe echo 10.20.21.1
set probe frequency 5
set link-group MPLS fallback INET
!
pfr-map PFR 20
match pfr learn list DATA-LEARN-LIST
set periodic 90
set delay threshold 25
set mode monitor active
set resolve delay priority 1 variance 10
set active-probe echo 10.30.31.1
set probe frequency 5
set link-group INET fallback MPLS
ip prefix-list DATA
seq 5 permit 10.30.0.0/24
ip prefix-list APPLICATION
seq 5 permit 10.20.0.0/24
驗證
案例1:父路由通過邊界路由器上的靜態路由獲取
在此場景中,流向目標10.20.20.1和10.30.30.1的流量如下。下面是父路由在R4和R5上的樣子。
R4#show ip route
--output suppressed--
S 10.20.0.0/16 [1/0] via 10.0.68.8
S 10.30.0.0/16 [1/0] via 10.0.68.8
R5#show ip route
--output suppressed--
S 10.20.0.0/16 [1/0] via 10.0.57.7
S 10.30.0.0/16 [1/0] via 10.0.57.7
流量流動時,PfRv2會獲知流量字首,流量會進入INPOLICY狀態,如下圖輸出所示。
R3#show pfr master traffic-class
OER Prefix Statistics:
--output suppressed--
DstPrefix Appl_ID Dscp Prot SrcPort DstPort SrcPrefix
Flags State Time CurrBR CurrI/F Protocol
PasSDly PasLDly PasSUn PasLUn PasSLos PasLLos EBw IBw
ActSDly ActLDly ActSUn ActLUn ActSJit ActPMOS ActSLos ActLLos
--------------------------------------------------------------------------------
10.20.20.0/24 N N N N N N
INPOLICY 31 10.4.4.4 Et1/0 STATIC
N N N N N N N N
1 2 0 0 N N N N
10.30.30.0/24 N N N N N N
INPOLICY 30 10.5.5.5 Et1/0 STATIC
N N N N N N N N
4 2 0 0 N N N N
從下面可以看到,R4(10.4.4.4)路由器注入了更具體的路由10.20.20.0/24。此自動生成的路由自動使用標籤值5000標籤。此更具體的更佳路由使R4成為發往10.20.20.0/24的流量的更好BR。
R4#show pfr border routes static
Flags: C - Controlled by oer, X - Path is excluded from control,
E - The control is exact, N - The control is non-exact
Flags Network Parent Tag
CE 10.20.20.0/24 10.20.0.0/16 5000
XN 10.30.30.0/24
R4#show ip route 10.20.20.0 255.255.255.0
Routing entry for 10.20.20.0/24
Known via "static", distance 1, metric 0
Tag 5000
Redistributing via ospf 100
Routing Descriptor Blocks:
* 10.0.46.6, via Ethernet1/0
Route metric is 0, traffic share count is 1
Route tag 5000
同樣,在R5上也可以看到類似行為,它會注入更具體的路由10.30.30.0/24,並且標籤為5000。這使得R5成為路由10.30.30.0/24流量的合適候選。這就是PfRv2優先路由流量的方式,如上述「show pfr master traffic-class」所示。
R5#show pfr border routes static
Flags: C - Controlled by oer, X - Path is excluded from control,
E - The control is exact, N - The control is non-exact
Flags Network Parent Tag
XN 10.20.20.0/24
CE 10.30.30.0/24 10.30.0.0/16 5000
R5#show ip route 10.30.30.0 255.255.255.0
Routing entry for 10.30.30.0/24
Known via "static", distance 1, metric 0
Tag 5000
Redistributing via ospf 100
Routing Descriptor Blocks:
* 10.0.57.7, via Ethernet1/0
Route metric is 0, traffic share count is 1
Route tag 5000
如果有多個邊界路由器(就像本例中一樣),這些自動生成的靜態路由必須手動重新分發到IGP中,以便它可以到達其他邊界路由器,而且它們可以根據由選定BR生成的更具體路由來路由流量。
案例2:通過OSPF學習父路由
任何未通過BGP、EIGRP或靜態路由獲知的父路由都使用基於策略的路由(PBR)進行控制。 PfRv2會注入動態路由對映和訪問清單來控制流量。以下是R4和R5上OSPF父路由的樣子。
R4#show ip route
--output suppressed--
O E2 10.20.0.0/16 [110/20] via 10.0.46.6, 02:16:35, Ethernet1/0
O E2 10.30.0.0/16 [110/20] via 10.0.46.6, 02:16:35, Ethernet1/0
R5#show ip route
--output suppressed--
O E2 10.20.0.0/16 [110/20] via 10.0.57.7, 02:18:20, Ethernet1/0
O E2 10.30.0.0/16 [110/20] via 10.0.57.7, 02:18:20, Ethernet1/0
當PfRv2必須通過基於策略的路由控制流量時,它需要BR之間的直接連線介面。此直接連線的鏈路可以是物理連線或GRE隧道。此隧道必須手動建立並在PfRv2邊界定義中配置為內部介面。
R4
interface tunnel 0 // Defining GRE tunnel for policy routing of traffic.
ip add 10.0.45.4
tunnel source 10.0.24.4
tunnel destination 10.0.25.5
R5
interface tunnel 0
ip add 10.0.45.5
tunnel source 10.0.25.5
tunnel destination 10.0.24.4
border 10.4.4.4 key-chain pfr
interface Tunnel0 internal // Packets would be policy routed to selected BR using this Tunnel.
interface Ethernet1/0 external
interface Ethernet1/2 internal
link-group MPLS
!
border 10.5.5.5 key-chain pfr
interface Tunnel0 internal // Packets would be policy routed to selected BR using this Tunnel.
interface Ethernet1/3 internal
interface Ethernet1/0 external
link-group INET
R3#show pfr master traffic-class
OER Prefix Statistics:
--output suppressed--
DstPrefix Appl_ID Dscp Prot SrcPort DstPort SrcPrefix
Flags State Time CurrBR CurrI/F Protocol
PasSDly PasLDly PasSUn PasLUn PasSLos PasLLos EBw IBw
ActSDly ActLDly ActSUn ActLUn ActSJit ActPMOS ActSLos ActLLos
--------------------------------------------------------------------------------
10.20.20.0/24 N N N N N N
INPOLICY @8 10.4.4.4 Et1/0 RIB-PBR
N N N N N N N N
2 1 0 0 N N N N
10.30.30.0/24 N N N N N N
INPOLICY 82 10.5.5.5 Et1/0 RIB-PBR
N N N N N N N N
1 1 0 0 N N N N
根據PfRv2定義的策略,它為10.20.20.0/24和10.30.30.0/24提供最佳出口路由器(BR)。例如,當發往10.20.20.0/24的流量到達R5(10.5.5.5)(而不是選定的BR)時,會自動注入動態路由對映和訪問清單,以將流量路由到選定的BR R4(10.4.4.4)。 資料包是通過之前定義的隧道介面路由的策略。
R5#show route-map dynamic
route-map OER_INTERNAL_RMAP, permit, sequence 0, identifier 436207617
Match clauses:
ip address (access-lists): oer#1
Set clauses:
ip next-hop 10.0.45.4
interface Tunnel0 // Tunnel is used to PBR traffic to R4.
Policy routing matches: 314076 packets, 16960104 bytes
R5#show ip access-lists dynamic
Extended IP access list oer#1
1073741823 permit ip any 10.20.20.0 0.0.0.255 (315125 matches)
2147483647 deny ip any any (314955 matches)