驗證理論
Ⅰ
首先路由一定是下一跳可達+關閉了同步 //只有best的路由才會被傳遞,只對best的路由進行選路
BGP路由優選規則:
當到達同一個目的網段存在多條路由時,BGP通過如下的次序進行路由優選:
1.優選Preferred-Value屬性值最大的路由
2.優選Local-Preference屬性值最大的路由
3.本地始發的BGP路由優於從其他對等體學習到的路由,本地始發的路由優先級:優選手動聚合>自動聚合>network>import>從對等體學到的
4.優選AS Path屬性值最短的路由
5.優選Origin屬性最優的路由。Origin屬性值按優先級從高到低的排列是:IGP.EGP及Incomplete
6.優選MED屬性值最小的路由
7.優選從EBGP對等體學來的路由(EBGP路由優先級高於IBGP路由)
8.優選到Next Hop的IGP度量值最小的路由
9.BGP負載均衡(AS-PATH 要求長度和路徑完全相同。路由表才會限時負載均衡)
10.優選Cluster List最短的路由
11.優選Router ID(Orginator ID)最小的設備通告的路由
12.優選具有最小IP地址的對等體通告的路由
ⅡAS-PATH FILTER+正則表達式
實驗拓撲
初始配置及結果
AS內建立IBGP鄰居,AS之間建立EBGP鄰居,AR1和AR3之間存在IBGP鄰居。為破IBGP防環機制,AR2,AR3均為反射器。AR2的客戶端是AR1,AR3的客戶端是AR1 AR4
一.
實驗目的:
驗證BGP12路由優選原則
實驗步驟
首先在AR5,AR6上使用network方式引入環回口
第一步:優選首選值Preferred-Value(PrefVal)屬性值最大的路由
協議首選值(PrefVal,可選非傳遞)是華為設備的特有屬性,該屬性僅在本地有效,無法向任何BGP鄰居(包括IBGP和EBGP)傳遞,且只能在入方向配置,因為無法傳遞,所以在出方向配置沒有意義
初始結果下,AR5上優選來自AR6的150.1.6.6(選擇原因查看第四步),更改來自AR1的150.1.6.6的路由的首選優先級為10,此時AR5優選來自AR1的150.1.6.6 /32路由
[AR5]ip ip-prefix NET6 permit 150.1.6.6 32
[AR5]route-policy SET-PRE permit node 10
[AR5-route-policy]if-match ip-prefix NET6
[AR5-route-policy]apply preferred-value 10
[AR5]route-policy SET-PRE permit node 20
[AR5-bgp]peer 155.1.15.1 route-policy SET-PRE import
[AR5]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 150.1.5.5/32 0.0.0.0 0 0 i
*> 150.1.6.6/32 155.1.15.1 10 100 300i
* 155.1.56.6 0 0 300i
* 155.1.45.4 0 100 300i
查看路由明細發現
[AR5]dis bgp routing-table 150.1.6.6
BGP local router ID : 155.1.56.5
Local AS number : 200
Paths: 3 available, 1 best, 1 select
BGP routing table entry information of 150.1.6.6/32:
From: 155.1.15.1 (155.1.12.1)
Route Duration: 00h00m09s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 155.1.15.1
Qos information : 0x0
AS-path 100 300, origin igp, pref-val 10, valid, external, best, select, active, pre 255
Advertised to such 3 peers:
155.1.45.4
155.1.15.1
155.1.56.6
BGP routing table entry information of 150.1.6.6/32:
From: 155.1.56.6 (155.1.56.6)
Route Duration: 01h13m10s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 155.1.56.6
Qos information : 0x0
AS-path 300, origin igp, MED 0, pref-val 0, valid, external, pre 255, not preferred for PreVal
Not advertised to any peer yet
AR5會嘗試將本路由表中最優的路由發出,但是不會攜帶首選值
[AR5]dis bgp routing-table peer 155.1.56.6 advertised-routes 150.1.6.6
BGP local router ID : 155.1.56.5
Local AS number : 200
BGP routing table entry information of 150.1.6.6/32:
From: 155.1.15.1 (155.1.12.1)
Route Duration: 00h02m22s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 155.1.15.1
Advertised nexthop: 155.1.56.5
Qos information : 0x0
AS-path 200 100 300, origin igp
第二步:優選Local-Preference屬性值最大的路由
本地優先級(LocPrf,公認任意)用來在AS內部選擇去往目的網段的最優路徑。只能在IBGP對等體之間傳遞,不能在EBGP對等體之間傳遞,如果EBGP對等體間收到的路由的路徑屬性中攜帶了Local Preference,則會進行錯誤處理。但是EBGP對等體在接收這條路由之后,會在本地為這條路由賦予一個缺省Local-Preference值(100),然后再將路由傳遞給自己的IBGP對等體
初始狀態下AR2會優選來自AR1的150.1.1.1/32的路由(參考第八步:優選到Next Hop的IGP度量值最小的路由),通過Local-Preference設置讓AR2優選來自AR4的150.1.1.1/32的路由
[AR4]ip ip-prefix NET5 permit 150.1.5.5 32
[AR4]route-policy SET-LP permit node 10
[AR4-route-policy]if-match ip-prefix NET5
[AR4-route-policy]apply local-preference 101
[AR4]route-policy SET-LP permit node 20
[AR4-bgp]peer 155.1.45.5 route-policy SET-LP import
[AR2]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 150.1.5.5/32 150.1.4.4 0 101 0 200i
*>i 150.1.6.6/32 150.1.4.4 0 100 0 300i
此時AR2上僅剩下從4.4過來的150.1.5.5的路由了。因為AR4面向整個AS100傳遞的150.1.5.5的本地優先級都是101,所以AR1上也會經過選路認為從AR4到AR1過來的150.1.5.5優於直接從AR5到AR1的150.1.5.5,所以AR1從AR2收到的150.1.5.5為最優,從AR5收到的150.1.5.5不是最優,不是最優不傳遞
第三步:本地始發的BGP路由優於從其他對等體學習到的路由,本地始發的路由優先級:優選手動聚合>自動聚合>network>import>從對等體學到的
在AR6上新增加環回口Lo 1 接口地址也為150.1.5.5 ,引入BGP,並且在AR5上干掉由AR6引入的150.1.5.5的AS-PATH,至此,AR5上本地的150.1.5.5和AR6過來的150.1.5.5的首選值,本地優先級,以及AS-PATH都相同,但是AR5還是選擇本地的150.1.5.5最優,因為本地始發的BGP路由優於從其他對等體學習到的路由
[AR6-bgp]network 150.1.5.5 32
[AR5]ip ip-prefix NET5 permit 150.1.5.5 32
[AR5]route-policy SET-AS-PATH permit node 10
[AR5-route-policy]if-match ip-prefix NET5
[AR5-route-policy]apply as-path none overwrite
[AR5]route-policy SET-AS-PATH permit node 20
[AR5-bgp]peer 155.1.56.6 route-policy SET-AS-PATH import
[AR5]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 150.1.5.5/32 0.0.0.0 0 0 i
* 155.1.56.6 0 0 i
*> 150.1.6.6/32 155.1.56.6 0 0 300i
* 155.1.15.1 0 100 300i
* 155.1.45.4 0 100 300i
第四步:優選AS Path屬性值最短的路由
初始結果下AR5上的BGP路由表為:
150.1.6.6 /32選擇下一跳為155.1.56.6最優的原因:
首先AR5上可以從3條路徑收到150.1.6.6/32的路由:AR6->AR5;AR6->4->3->2->1->5;AR6->AR4->AR5
1.三條路由都沒有設置首選值,即prefval(preferred-value)相同
2.三條路由都是通過EBGP鄰居傳遞,不攜帶本地優先級,即LocPrf(local-preference)相同
3.3條路由NextHop既不是0.0.0.0也不是127.0.0.1,都是從EBGP鄰居學到,即三條路徑都不是本地生成都是從對等體學到
4.因為來自155.1.56.6的PATH(AS PATH)最短所以優選來自155.1.56.6的路由,驗證了第四條選路原則:優選AS PATH屬性值最短的路由
[AR5]dis bgp routing-table 150.1.6.6
BGP local router ID : 155.1.56.5
Local AS number : 200
Paths: 3 available, 1 best, 1 select
BGP routing table entry information of 150.1.6.6/32:
From: 155.1.56.6 (155.1.56.6)
Route Duration: 01h20m10s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 155.1.56.6
Qos information : 0x0
AS-path 300, origin igp, MED 0, pref-val 0, valid, external, best, select, active, pre 255
Advertised to such 3 peers:
155.1.45.4
155.1.15.1
155.1.56.6
BGP routing table entry information of 150.1.6.6/32:
From: 155.1.15.1 (155.1.12.1)
Route Duration: 00h03m47s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 155.1.15.1
Qos information : 0x0
AS-path 100 300, origin igp, pref-val 0, valid, external, pre 255, not preferred for AS-Path
Not advertised to any peer yet
BGP routing table entry information of 150.1.6.6/32:
From: 155.1.45.4 (155.1.46.4)
Route Duration: 01h20m11s
Direct Out-interface: GigabitEthernet0/0/2
Original nexthop: 155.1.45.4
Qos information : 0x0
AS-path 100 300, origin igp, pref-val 0, valid, external, pre 255, not preferred for router ID //這個和155.1.15.1相比是因為router id 通告者比小落選,具體在11步講
Not advertised to any peer yet
第五步:優選Origin屬性最優的路由。Origin屬性值按優先級從高到低的排列時:IGP,EGP及Incomplete
初始結果下AR2優選來自AR1的150.1.5.5的路由。利用起源屬性,使得AR2優選來自AR4的150.1.5.5的路由
[AR1]ip ip-prefix NET5 permit 150.1.5.5 32
[AR1]route-policy SET-ORI permit node 10
[AR1-route-policy]if-match ip-prefix NET5
[AR1-route-policy]apply origin incomplete
[AR1]route-policy SET-ORI permit node 20
[AR1-bgp]peer 155.1.15.5 route-policy SET-ORI import
BGP routing table entry information of 150.1.5.5/32:
From: 155.1.15.5 (155.1.56.5)
Route Duration: 00h00m12s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 155.1.15.5
Qos information : 0x0
AS-path 200, origin incomplete, MED 0, pref-val 0, valid, external, pre 255, no
t preferred for Origin
第六步:優選MED屬性最小的路由
上一篇已經驗證過,不重復驗證
第七步:優選從EBGP對等體學來的路由(EBGP路由優先級高於IBGP路由)
初始狀態下,AR1上收到兩條去往150.1.5.5的路由,優選從EBGP鄰居155.1.15.5傳遞過來的150.1.5.5 /32的路由
分析:
1.從AR5和AR4進來的150.1.5.5的首選值相同都是0
2.本地優先級相同,如果顯示為空,則是默認的100
3.都不是本地生成的,而是外部引入的
4.經過的AS-PATH長度相同,都只有一個200
5.起源屬性相同,都是i
6.MED相同,都是0
7.從EBGP對等體155.1.15.5學來的路由優選於從IBGP對等體150.1.4.4學來的路由
[AR1]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 150.1.5.5/32 155.1.15.5 0 0 200i
* i 150.1.4.4 0 100 0 200i
*>i 150.1.6.6/32 150.1.4.4 0 100 0 300i
* i 150.1.4.4 0 100 0 300i
* 155.1.15.5 0 200 300i
[AR1]dis bgp routing-table 150.1.5.5
BGP local router ID : 155.1.12.1
Local AS number : 100
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 150.1.5.5/32:
From: 155.1.15.5 (155.1.56.5)
Route Duration: 00h17m09s
Direct Out-interface: GigabitEthernet0/0/1
Original nexthop: 155.1.15.5
Qos information : 0x0
AS-path 200, origin igp, MED 0, pref-val 0, valid, external, best, select, acti
ve, pre 255
Advertised to such 2 peers:
150.1.2.2
150.1.3.3
BGP routing table entry information of 150.1.5.5/32:
From: 150.1.3.3 (155.1.23.3)
Route Duration: 00h57m29s
Relay IP Nexthop: 155.1.12.2
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 150.1.4.4
Qos information : 0x0
AS-path 200, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre
255, IGP cost 30, not preferred for peer type
Originator: 155.1.46.4
Cluster list: 155.1.23.3
Not advertised to any peer yet
第八步:優選到Next Hop的IGP度量值最小的路由
初始狀態下,AR2上收到兩條去往150.1.5.5的路由:分別來自AR1和AR4(AR4只會傳遞最優路由,所以在AR2上看到來自AR4的路由就只有一條)。AR2依據優選到Next Hop的IGP度量值最小的路由,選擇來自AR1的路由
分析:
1.兩條路由都沒有設置首選值
2.兩條路由的本地優先級都是0
3.兩條路由的下一跳都不是0.0.0.0或者127.0.0.1,即都是從BGP對等體學到的,而不是本地生成的路由
4.兩條路由的AS PATH屬性值長度相同
5.兩條路由的origin屬性相同,來源都是network
6.兩條路由的MED相同,都為0
7.兩條路由都是來源於IBGP鄰居學到的
8.因為AR2去往150.1.1.1的度量值為10,小於去往150.1.4.4的度量值20,所以優選來自150.1.1.1的路由
[AR2]dis bgp routing-table
Total Number of Routes: 3
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 150.1.5.5/32 150.1.1.1 0 100 0 200i
* i 150.1.4.4 0 100 0 200i
*>i 150.1.6.6/32 150.1.4.4 0 100 0 300i
[AR2]dis ip routing-table protocol isis
150.1.1.1/32 ISIS-L2 15 10 D 155.1.12.1 GigabitEthernet0/0/0
150.1.4.4/32 ISIS-L2 15 20 D 155.1.23.3 GigabitEthernet0/0/1
[AR2]dis bgp routing-table 150.1.5.5
BGP local router ID : 155.1.12.2
Local AS number : 100
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 150.1.5.5/32:
RR-client route.
From: 150.1.1.1 (155.1.12.1)
Route Duration: 01h27m40s
Relay IP Nexthop: 155.1.12.1
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 150.1.1.1
Qos information : 0x0
AS-path 200, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, active, pre 255, IGP cost 10
Advertised to such 1 peers:
150.1.3.3
BGP routing table entry information of 150.1.5.5/32:
From: 150.1.3.3 (155.1.23.3)
Route Duration: 01h27m40s
Relay IP Nexthop: 155.1.23.3
Relay IP Out-Interface: GigabitEthernet0/0/1
Original nexthop: 150.1.4.4
Qos information : 0x0
AS-path 200, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, pre 255, IGP cost 20, not preferred for IGP cost
Originator: 155.1.46.4
Cluster list: 155.1.23.3
Not advertised to any peer yet
手動增加AR2->AR1的cost,會發現又出現變化
[AR2-GigabitEthernet0/0/0]isis cost 25
[AR2]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 150.1.5.5/32 150.1.4.4 0 100 0 200i
* i 150.1.1.1 0 100 0 200i
*>i 150.1.6.6/32 150.1.4.4 0 100 0 300i
第九步:BGP負載均衡(AS-PATH要求長度和路徑完全相同,路由表才會顯示負載均衡)
一般情況下,只有“BGP選擇路由的策略”所描述的前8個屬性完全相同,BGP路由之間才能相互等價,實現BGP的負載分擔。但路由負載分擔的規則也可以通過配置來改變,如忽略路由AS-Path屬性的比較,但這些配置現需要確保不會引起路由環路
需要先開啟負載分擔:
- 執行命令maximum load-balancing [ ebgp | ibgp ] number [ ecmp-nexthop-changed ],配置BGP負載分擔的最大等價路由條數。
缺省情況下,BGP負載分擔的最大等價路由條數為1,即不進行負載分擔。
實現AR6上從5和4到150.1.5.5負載分擔
[AR6]ip ip-prefix NET5 permit 150.1.5.5 32
[AR6]route-policy SET-AS-PATH permit node 10
[AR6-route-policy]if-match ip-prefix NET5
[AR6-route-policy]apply as-path 200 additive
[AR6-bgp]peer 155.1.56.5 route-policy SET-AS-PATH import
[AR6]route-policy SET-AS-PATH permit node 20
[AR6-bgp]maximum load-balancing ebgp 2 //開啟EBGP負載均衡最多兩條等價路由
此時更改完成。前8項都相同
分析:
1.首選值相同,都為0
2.本地優先級相同,都沒顯示,都是100
3.nexthop都不是0.0.0.0或者127.0.0.1,即都不是本地生成的路由,而是從對等體學到的
4.經過的AS PATH 數量相同
5.起源屬性相同,都是i
6.MED相同,都是0,沒寫默認是0
7.都是從EBGP對等體鄰居學到,不存在EBGP優於IBGP的比較
8.都是從EBGP學到,不存在到NEXT-HOP的IGP度量值最小的路由
9.負載均衡
[AR6]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 150.1.5.5/32 155.1.46.4 0 100 200i
* 155.1.56.5 0 0 200 200i
*> 150.1.6.6/32 0.0.0.0 0 0 i
[AR6]dis bgp routing-table 150.1.5.5
BGP local router ID : 155.1.56.6
Local AS number : 300
Paths: 2 available, 1 best, 1 select
[AR6]dis ip routing-table
150.1.5.5/32 EBGP 255 0 D 155.1.46.4 GigabitEthernet0/0/2
重新更改AS-PATH,讓他們不僅數量相同,且值也相同之后
實現了負載均衡
[AR6]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 150.1.5.5/32 155.1.46.4 0 100 200i
* 155.1.56.5 0 0 100 200i
*> 150.1.6.6/32 0.0.0.0 0 0 i
[AR6]dis bgp routing-table 150.1.5.5
BGP local router ID : 155.1.56.6
Local AS number : 300
Paths: 2 available, 1 best, 2 select
[AR6]dis ip routing-table 150.1.5.5
Destination/Mask Proto Pre Cost Flags NextHop Interface
150.1.5.5/32 EBGP 255 0 D 155.1.46.4 GigabitEthernet 0/0/2
EBGP 255 0 D 155.1.56.5 GigabitEthernet 0/0/0
所以要形成負載均衡,不僅要求AS長度相同,也要求AS取值相同
[AR6-bgp]load-balancing as-path-ignore //可以通過配置,使得忽略as-path不同,直接形成負載均衡
第十步:優選Cluster List最短的路由
首先增加從AR4進來的150.1.5.5的本地優先級,讓AS100內的路由器都優選從4.4進來的150.1.5.5路由
[AR4]ip ip-prefix NET5 permit 150.1.5.5 32
[AR4]route-policy SET-LOCAL permit node 10
[AR4-route-policy]if-match ip-prefix NET5
[AR4-route-policy]apply local-preference 101
[AR4-bgp]peer 150.1.3.3 route-policy SET-LOCAL export
此時AR2,AR3都反射了150.1.5.5的路由給到AR1.
1.首選值相同,都是0
2.本地優先級相同,都是101
3.都不是本地生成的路由,都是從鄰居學到的路由
4.as-path 個數相同
5.origin屬性相同,都是i
6.MED相同,都是0
7.都是從IBGP學到,不存在E優於I
8.下一跳相同,都是150.1.4.4,所以不存在去往下一跳的開銷越小越優先
9.不存在負載均衡
10.因為從AR3過來的路由只經歷了一個反射器,認為這個路由更優,所以優選AR3過來的路由
[AR4]route-policy SET-LOCAL permit node 20
[AR1]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 150.1.5.5/32 150.1.4.4 0 101 0 200i
* i 150.1.4.4 0 101 0 200i
* 155.1.15.5 0 0 200i
*>i 150.1.6.6/32 150.1.4.4 0 100 0 300i
* i 150.1.4.4 0 100 0 300i
* 155.1.15.5 0 200 300i
[AR1]dis bgp routing-table 150.1.5.5
BGP local router ID : 155.1.12.1
Local AS number : 100
Paths: 3 available, 1 best, 1 select
BGP routing table entry information of 150.1.5.5/32:
From: 150.1.3.3 (155.1.23.3)
Route Duration: 00h03m14s
Relay IP Nexthop: 155.1.12.2
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 150.1.4.4
Qos information : 0x0
AS-path 200, origin igp, MED 0, localpref 101, pref-val 0, valid, internal, bes
t, select, active, pre 255, IGP cost 30
Originator: 155.1.46.4
Cluster list: 155.1.23.3
Advertised to such 1 peers:
155.1.15.5
BGP routing table entry information of 150.1.5.5/32:
From: 150.1.2.2 (155.1.12.2)
Route Duration: 00h03m14s
Relay IP Nexthop: 155.1.12.2
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 150.1.4.4
Qos information : 0x0
AS-path 200, origin igp, MED 0, localpref 101, pref-val 0, valid, internal, pre
255, IGP cost 30, not preferred for Cluster List
Originator: 155.1.46.4
Cluster list: 155.1.12.2, 155.1.23.3
Not advertised to any peer yet
第十一步:優選Router ID(Orginator ID)最小的設備通告的路由
初始條件下,在AR6上,增加AR5->AR6的一個經過的AS-PATH
1.首選值相同,都是0
2.本地優先級相同,都是100
3.都不是本地生成的路由,而是從對等體學到的
4.經過的AS PATH 數量相同
5.起源屬性相同,都是i
6.MED相同,都是0
7.都是從EBGP鄰居學到,不存在EBGP學到的優於IBGP的比較
8.都是直接從EBGP學到,去往nexthop的IGP開銷都是直連
9.path值不相同,無法負載均衡
10.沒有經過反射器,不存在cluster id
11.因為鄰居155..46.4的router id 小於155.1.56.5的router id ,所以優選從155.1.46.4過來的150.1.5.5的路由
[AR6]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 150.1.5.5/32 155.1.46.4 0 100 200i
* 155.1.56.5 0 0 200 200i
*> 150.1.6.6/32 0.0.0.0 0 0 i
[AR6]dis bgp routing-table 150.1.5.5
BGP local router ID : 155.1.56.6
Local AS number : 300
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 150.1.5.5/32:
From: 155.1.46.4 (155.1.46.4)
Route Duration: 00h26m31s
Direct Out-interface: GigabitEthernet0/0/2
Original nexthop: 155.1.46.4
Qos information : 0x0
AS-path 100 200, origin igp, pref-val 0, valid, external, best, select, active,
pre 255
Advertised to such 2 peers:
155.1.56.5
155.1.46.4
BGP routing table entry information of 150.1.5.5/32:
From: 155.1.56.5 (155.1.56.5)
Route Duration: 00h00m51s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 155.1.56.5
Qos information : 0x0
AS-path 200 200, origin igp, MED 0, pref-val 0, valid, external, pre 255, not p
referred for router ID
Not advertised to any peer yet
第十二步:優選具有最小IP地址的對等體通告的路由
要比到第12步,可以兩個路由器之間連兩根線,也可以直接在兩個鄰居之間一條線用不同的接口建兩個鄰居
在AR5和AR6之間再利用環回口建立鄰居,暫時忽略掉除4,5之間的其他鄰居關系
[AR5-bgp]peer 155.1.45.4 ignore //手動忽略鄰居關系
[AR5]dis bgp peer
150.1.6.6 4 300 6 7 0 00:01:17 Established 1
155.1.15.1 4 100 0 0 0 00:00:31 Idle(Admin) 0
155.1.45.4 4 100 0 0 0 00:00:22 Idle(Admin) 0
155.1.56.6 4 300 47 47 0 00:40:54 Established 1
1.首選值相同,都是0
2.本地優先級相同,都是100
3.都是從BGP學習到的
4.AS PATH長度相同
5.起源屬性一樣
6.MED一樣
7.都是從EBGP學到,不存在EBGP學的優於IBGP學到的比較
8.去往下一跳的IGP開銷最小,談不上
9.未開啟負載均衡
10.沒有經過反射器,沒有cluster id
11.發送者的router id 相同,都是AR5的router id
12.因為150.1.5.5的IP地址小於155.1.56.5,所以優選從鄰居150.1.5.5過來的路由
[AR6]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.1.5.5/32 150.1.5.5 0 0 200i
* 155.1.56.5 0 0 200i
[AR6]dis bgp routing-table 10.1.5.5
BGP local router ID : 155.1.56.6
Local AS number : 300
Paths: 2 available, 1 best, 2 select
BGP routing table entry information of 10.1.5.5/32:
From: 150.1.5.5 (155.1.56.5)
Route Duration: 00h04m39s
Relay IP Nexthop: 155.1.56.5
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 150.1.5.5
Qos information : 0x0
AS-path 200, origin igp, MED 0, pref-val 0, valid, external, best, select, acti
ve, pre 255
Advertised to such 2 peers:
150.1.5.5
155.1.56.5
BGP routing table entry information of 10.1.5.5/32:
From: 155.1.56.5 (155.1.56.5)
Route Duration: 00h04m39s
Direct Out-interface: GigabitEthernet0/0/0
Original nexthop: 155.1.56.5
Qos information : 0x0
AS-path 200, origin igp, MED 0, pref-val 0, valid, external, select, active, pr
e 255, not preferred for peer address
BGP超網路由(華為默認禁用)
BGP通告的路由與Next-hop在相同網段,即BGP超網路由。比如說用環回口建立鄰居,又引入了環回口作為BGP路由,傳出去之后,鄰居認為下一跳和收到的路由前綴是相同網段,不傳遞
華為默認不傳遞BGP超網路由(ENSP不支持禁用此功能)
bgp 100
supernet unicast advertise enable //打開BGP超網路由傳遞功能
在AR6上禁用除了150.1.5.5之外的其他所有鄰居,此時查看路由
[AR6]dis bgp peer
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
150.1.5.5 4 200 6 8 0 00:01:18 Established 2
155.1.46.4 4 100 0 0 0 00:01:52 Idle(Admin) 0
155.1.56.5 4 200 0 0 0 00:00:09 Idle(Admin) 0
此時查看路由
[AR6]dis bgp routing-table
BGP Local router ID is 155.1.56.6
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 3
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.1.5.5/32 150.1.5.5 0 0 200i
150.1.5.5/32 150.1.5.5 0 0 200i
*> 150.1.6.6/32 0.0.0.0 0 0 i
此時150.1.5.5連*都不帶了,意思是甚至不是有效。是因為AR6收到的150.1.5.5 /32和去往這個路由的下一跳150.1.5.5是同一網段的,所以被認為是BGP超網路由,不傳遞
路由匹配工具:AS-Path Filter
AS-Path Filter是將BGP中的AS-Path屬性作為匹配條件的過濾器,利用BGP路由攜帶的AS-PATH列表對路由進行過濾
在不希望接收某些AS的路由時,可以利用AS-Path Filter對攜帶這些AS號的路由進行過濾,從而實現拒絕某些路由
恢復AR5,6的鄰居建立,通過as-path filter實現AR6不接收經過AS100的任何路由(不包含始發AS 100)
未配置前
[AR6]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.1.5.5/32 150.1.5.5 0 0 200i
* 155.1.56.5 0 0 200i
* 155.1.46.4 0 100 200i
*> 150.1.5.5/32 155.1.56.5 0 0 200i
* 155.1.46.4 0 100 200i
150.1.5.5 0 0 200i
*> 150.1.6.6/32 0.0.0.0 0 0 i
配置:
[AR6]ip as-path-filter DENY-AS100 deny _100_
[AR6]ip as-path-filter DENY-AS100 permit .* //和route policy一樣,因為是在鄰居上直接引用as-path-filter或者route-policy,所以一定要記得最后要允許其他的路由條目過來
[AR6-bgp]peer 155.1.46.4 as-path-filter DENY-AS100 import
查看
[AR6]dis bgp routing-table
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.1.5.5/32 150.1.5.5 0 0 200i
* 155.1.56.5 0 0 200i
*> 150.1.5.5/32 155.1.56.5 0 0 200i
150.1.5.5 0 0 200i
*> 150.1.6.6/32 0.0.0.0 0 0 i
此時在AR3上增加10.1.3.3,發布到BGP中,在AR6上是可以看到的,因為始發AS100的100i不滿足_100_
正則表達式是按照一定的模板來匹配字符串的公式,由普通字符(例如字符a到z)和特殊字符組成