使用協議首選值影響選路
阿新 • • 發佈:2018-10-12
source cal 5.5.0 src complete ocp 出口 stat 路由
prefVal:華為私有,僅在本地有意義,不會更新給鄰居,不能用於export方向。prefval的值默認是0,越大越優先。它的作用是用來影響自己的出站流量的,需要針對路由註入方向的鄰居來做策略。有兩種做策略的方法:
A. 針對一個鄰居完全的修改,從該鄰居更新來的,都更改,此時不需要方向,該鄰居通告的路由,都會應用這個首選值。
B.明細的修改,調用route-policy,些時需要方向,只能是import方向。
實驗一:使用pref-val來影響選路,針對一個鄰居發送過來的路由,全部應用一個較大的Pref-val,以獲得優選。我們在R4上使用pref-val來實驗選路,讓它走R3去往AS100
在通告完路由以後,R4默認的BGP表如下,可以看到,因為R2有較小的router-id.所以R4優選R2做為下一跳去往R1通告的三條路由。
<R4>display bgp routing-table BGP Local router ID is 4.4.4.4 Status codes: * - valid, > - best, d - damped, h - history, i - internal, s - suppressed, S - Stale Origin : i - IGP, e - EGP, ? - incomplete Total Number of Routes: 8 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 1.1.1.0/24 2.2.2.2 0 100 0 100i * i 3.3.3.3 0 100 0 100i *> 5.5.5.0/24 45.1.1.5 0 0 300i *>i 10.1.1.0/24 2.2.2.2 0 100 0 100i * i 3.3.3.3 0 100 0 100i *> 44.44.44.0/24 0.0.0.0 0 0 i *>i 100.1.1.0/24 2.2.2.2 0 100 0 100i * i 3.3.3.3 0 100 0 100i
<R4>display bgp routing-table 1.1.1.0 255.255.255.0 BGP local router ID : 4.4.4.4 Local AS number : 200 Paths: 2 available, 1 best, 1 select BGP routing table entry information of 1.1.1.0/24: From: 2.2.2.2 (2.2.2.2) Route Duration: 01h07m21s Relay IP Nexthop: 24.1.1.2 Relay IP Out-Interface: GigabitEthernet0/0/0 Original nexthop: 2.2.2.2 Qos information : 0x0 AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, active, pre 255, IGP cost 1 Advertised to such 1 peers: 45.1.1.5 BGP routing table entry information of 1.1.1.0/24: From: 3.3.3.3 (3.3.3.3) Route Duration: 01h07m21s Relay IP Nexthop: 34.1.1.3 Relay IP Out-Interface: GigabitEthernet0/0/1 Original nexthop: 3.3.3.3 Qos information : 0x0 AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre 255, IGP cost 1, not preferred for router ID Not advertised to any peer yet
現在,針對R4做設置,讓其去往1.1.1.0/24 10.1.1.0/24 100.1.1.0/24走R3
[R4-bgp]peer 3.3.3.3 preferred-value 100
在R4上查看BGP表以及針對1.1.1.0/24的路由,為什麽優選R3做為出口
[R4-bgp]display bgp routing-table
BGP Local router ID is 4.4.4.4
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 8
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.1.0/24 3.3.3.3 0 100 100 100i
* i 2.2.2.2 0 100 0 100i
*> 5.5.5.0/24 45.1.1.5 0 0 300i
*>i 10.1.1.0/24 3.3.3.3 0 100 100 100i
* i 2.2.2.2 0 100 0 100i
*> 44.44.44.0/24 0.0.0.0 0 0 i
*>i 100.1.1.0/24 3.3.3.3 0 100 100 100i
* i 2.2.2.2 0 100 0 100i
[R4-bgp]display bgp routing 1.1.1.0 255.255.255.0
BGP local router ID : 4.4.4.4
Local AS number : 200
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 1.1.1.0/24:
From: 3.3.3.3 (3.3.3.3)
Route Duration: 00h00m27s
Relay IP Nexthop: 34.1.1.3
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 3.3.3.3
Qos information : 0x0
AS-path 100, origin igp, MED 0, localpref 100, pref-val 100, valid, internal, best, select, active, pre 255, IGP cost 1
Advertised to such 1 peers:
45.1.1.5
BGP routing table entry information of 1.1.1.0/24:
From: 2.2.2.2 (2.2.2.2)
Route Duration: 01h11m56s
Relay IP Nexthop: 24.1.1.2
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 2.2.2.2
Qos information : 0x0
AS-path 100, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre 255, IGP cost 1, not preferred for PreVal(R4去往1.1.1.0/24的路由,沒有走R2 2.2.2.2是因為首選值不是最優的)
Not advertised to any peer yet
實驗二: 讓R4通過協議首選值來選擇R3做為下一跳,而去往10.1.1.0/24和100.1.1.0/24保持默認。
首先,我們將實驗一中的這條命令去掉:[R4-bgp] undo peer 3.3.3.3 preferred-value
針對特定路由使用Pref-val來做選路,需要調用Route-map來實驗
R4:
acl number 2000
rule 10 permit source 1.1.1.0 0
route-policy pref permit node 10
if-match acl 2000
apply preferred-value 123
#
route-policy pref permit node 20
bgp 200
peer 3.3.3.3 route-policy pref import
[R4]display bgp routing-table
BGP Local router ID is 4.4.4.4
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 8
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 1.1.1.0/24 3.3.3.3 0 100 123 100i
* i 2.2.2.2 0 100 0 100i
*> 5.5.5.0/24 45.1.1.5 0 0 300i
*>i 10.1.1.0/24 2.2.2.2 0 100 0 100i
* i 3.3.3.3 0 100 0 100i
*> 44.44.44.0/24 0.0.0.0 0 0 i
*>i 100.1.1.0/24 2.2.2.2 0 100 0 100i
* i 3.3.3.3 0 100 0 100i
現在,我們看到R4去往1.1.1.0/24的路由,選擇了R3做為下一跳,因為對R3設置了PrefVal為123,高於R2的PrefVal 0. 而針對10.1.1.0/24和100.1.1.10/24並沒有應用route-policy,所以其prefval保持默認的值,為0. R4去往這兩條路由,依舊選擇R2做為下一跳。
使用協議首選值影響選路