1. 程式人生 > >乾頤堂軍哥HCIE課程10-BGP的路由聯邦實施以及團體屬性操控路由

乾頤堂軍哥HCIE課程10-BGP的路由聯邦實施以及團體屬性操控路由

type equal date 3.3 sha clust reg 列表 code

BGP知識
拓撲圖
技術分享圖片
1.BGP的RR
1.1 RR的規則
切記:非非(非客戶端之間)不傳
1)從非客戶端收到的路由會更新給客戶端和ebgp鄰居
[R3]dis bgp routing-table 6.6.6.6

BGP local router ID : 10.1.35.3
Local AS number : 345
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 6.6.6.6/32:
From: 55.1.1.1 (10.1.35.5)
Route Duration: 00h09m31s
Relay IP Nexthop: 10.1.35.5

Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 55.1.1.1
Qos information : 0x0
AS-path 60, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, active, pre 255, IGP cost 48
Advertised to such 2 peers:
10.1.30.10
44.1.1.1 //更新給客戶端
2)從客戶端收到的路由會更新給所有的鄰居(客戶端和非客戶端、eBGP,不反射回該客戶端)

BGP local router ID : 10.1.35.3

Local AS number : 345
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 2.2.2.2/32:
RR-client route.
From: 44.1.1.1 (4.4.4.4)
Route Duration: 00h10m16s
Relay IP Nexthop: 10.1.35.5
Relay IP Out-Interface: GigabitEthernet0/0/0
Original nexthop: 44.1.1.1
Qos information : 0x0
AS-path 20, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, active, pre 255, IGP cost 144
Advertised to such 2 peers:
10.1.30.10 //更新給ebgp
55.1.1.1 //更新給非客戶端
3)從eBGP學習到的路由更新給客戶端和非客戶端

1.2 RR的防環屬性
簇(cluster),RR和它們的客戶端組成一個簇
reflector cluster-id 3.3.3.3 //可選配置
起源ID(originator ID)的防環現象:
Jan 14 2018 10:38:47.58.1-08:00 R4 RM/6/RMDEBUG:
BGP.Public : Error identified while receiving UPDATE message from the peer 55.1.1.1 and ignored
Reason: (ORIGINATORID equal to RouterID). //如果起源ID=RID,則不接收該路由。思路:1)是否產生了路由(路由始發者) 2)是否更新出去 3)路由是否被接受
簇ID(cluster id),
Jan 14 2018 10:52:06.970.4-08:00 R5 RM/6/RMDEBUG:
BGP.Public : Error identified while receiving UPDATE message from the peer 33.1.1.1 and ignored
Reason: (Received CLUSTERLIST Value greater than allowed loop count of ClusterID of the speaker). //由於簇list中包含了自身的簇ID,所以拒絕該路由!
6.6.6.6這條路由R5更新給R3,R3接收了,why?
只有路由被反射了,才會增加起源ID/簇ID屬性
dis bgp routing-table 2.2.2.2

BGP local router ID : 10.1.35.5
Local AS number : 345
Paths: 2 available, 1 best, 1 select
BGP routing table entry information of 2.2.2.2/32:
RR-client route.
From: 33.1.1.1 (10.1.35.3)
Route Duration: 00h01m59s
Relay IP Nexthop: 10.1.1.1
Relay IP Out-Interface: Serial1/0/0
Original nexthop: 44.1.1.1
Qos information : 0x0
AS-path 20, origin igp, MED 0, localpref 100, pref-val 0, valid, internal, best, select, active, pre 255, IGP cost 96
Originator: 4.4.4.4 //起源ID
Cluster list: 3.3.3.3 //簇列表
Advertised to such 2 peers:
66.1.1.1
44.1.1.1
1.3 層次化的RR+補充路由反射器情況下的下一跳
多層RR而已
[R3-bgp]peer 44.1.1.1 next-hop-local //不能實現需求

[R3-bgp]peer 44.1.1.1 route-policy NHOP export //RR上出方向應用策略無效(ENSP 390)
R4上:
[R4-bgp]peer 33.1.1.1 route-policy NHOP import
route-policy NHOP permit node 5
if-match acl 2006
apply ip-address next-hop 33.1.1.1 //如果匹配到acl20006調用的路由,修改下一跳為RR的更新源地址
route-policy NHOP permit node 10 //允許其他路由從RR更新
acl number 2006
rule 5 permit source 6.6.6.6 0
驗證:
<R4>dis 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: 4
Network NextHop MED LocPrf PrefVal Path/Ogn

> 2.2.2.2/32 10.1.24.2 0 0 20i
>i 6.6.6.0/28 55.1.1.1 100 0 60 123e //路由策略放行的路由,不做修改
*>i 6.6.6.6/32 33.1.1.1 0 100 0 60i //生效,修改了下一跳

2.聯邦
沒有改變iBGP的更新機制,所以不需要額外的防環規則
比如下一跳、本地優先級等屬性在整個聯邦保持不變
需求:
as345被配置為聯邦,R3和R4為成員as64512(私有as號碼的最小值),R5為成員as65535(私有as號碼的最大值),R3和R5構建聯邦as的ebgp鄰居
[R5-bgp]dis th
[V200R003C00]
#
bgp 65535
confederation id 345 //表明本as的“國家”身份
confederation peer-as 64512 //表明和成員as的eBGP鄰居關系
peer 33.1.1.1 as-number 64512
peer 33.1.1.1 ebgp-max-hop 255
peer 33.1.1.1 connect-interface LoopBack0 //不要忘記成員as的ebgp多跳也需要配置,否則ttl為1,報文無法到達對端
peer 33.1.1.1 next-hop-local //對成員as修改下一跳,否則路由不會優化
peer 66.1.1.1 as-number 60 //構建國家間的ebgp鄰居
peer 66.1.1.1 ebgp-max-hop 255
peer 66.1.1.1 connect-interface LoopBack0
<R5>dis bgp routing-table 2.2.2.2

BGP local router ID : 10.1.35.5
Local AS number : 65535
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 2.2.2.2/32:
From: 33.1.1.1 (10.1.35.3)
Route Duration: 00h02m08s
Relay IP Nexthop: 10.1.1.1
Relay IP Out-Interface: Serial1/0/0
Original nexthop: 44.1.1.1
Qos information : 0x0
AS-path (64512) 20, origin igp, MED 0, localpref 100, pref-val 0, valid, external-confed, best, select, active, pre 255, IGP cost 96
Advertised to such 1 peers:
66.1.1.1

3.BGP的團體屬性
最容易忽略的是:peer x.x.x.x advertise-community
團體屬性可以有多種應用方式,不同的應用結果不同
NETWORK、針對鄰居在出/入方向應用、引入路由的時候應用、聚合的時候應用
3.1 眾所周知的團體屬性(路由過濾相關)
INTERNET,默認屬性,所有路由都具備這個屬性
no-advertise,不更新路由給鄰居
aggregate 6.6.6.0 255.255.255.240 suppress-policy SUPPRESS attribute-policy ATTRIBUTE
//聚合路由時修改團體屬性
route-policy ATTRIBUTE permit node 10
apply community no-advertise
[R6-bgp]dis bgp rou 6.6.6.0

BGP local router ID : 0.0.6.6
Local AS number : 60
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 6.6.6.0/28:
Aggregated route.
Route Duration: 00h03m10s
Direct Out-interface: NULL0
Original nexthop: 127.0.0.1
Qos information : 0x0
Community:no-advertise //由於是路由在生成時就具備該屬性,所以不在更新給鄰居
針對鄰居應用的實例:
route-policy COMM permit node 5
if-match acl 2006
apply community no-advertise //僅僅對acl2006的路由做出團體屬性no-advertise
#
route-policy COMM permit node 10 //放行其他路由,不做團體屬性的修改
bgp 60
peer 55.1.1.1 advertise-community
peer 55.1.1.1 route-policy COMM export //針對鄰居調用
驗證結果:
<R5>dis bgp routing-table 6.6.6.6

BGP local router ID : 10.1.35.5
Local AS number : 65535
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 6.6.6.6/32:
From: 66.1.1.1 (0.0.6.6)
Route Duration: 00h00m11s
Relay IP Nexthop: 10.1.56.6
Relay IP Out-Interface: Serial2/0/0
Original nexthop: 66.1.1.1
Qos information : 0x0
Community:no-advertise //團體屬性
AS-path 60, origin igp, MED 0, pref-val 0, valid, external, best, select, active, pre 255, IGP cost 48
Not advertised to any peer yet //不更新給任何鄰居

no-export,不更新路由給真正的EBGP
此時R3和R4是否具備no-export屬性?沒有,因為默認不向鄰居通告團體屬性
R6:
route-policy COMM permit node 5
if-match acl 2006
apply community no-export //對acl2006命中的路由,增加“不通告給真正的ebgp”的團體屬性
#
route-policy COMM permit node 10 //對其他路由放心
peer 55.1.1.1 route-policy COMM export
[R5-bgp]peer 33.1.1.1 advertise-community
[R3-bgp]peer 44.1.1.1 advertise-community
[R3-bgp]peer 55.1.1.1 advertise-community
<R4>dis bgp routing-table 6.6.6.6

BGP local router ID : 4.4.4.4
Local AS number : 64512
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 6.6.6.6/32:
From: 33.1.1.1 (10.1.35.3)
Route Duration: 00h03m51s
Relay IP Nexthop: 10.1.1.1
Relay IP Out-Interface: Serial1/0/0
Original nexthop: 55.1.1.1
Qos information : 0x0
Community:no-export //團體屬性

no-export-subconfed,不更新路由給其他成員AS(local-as)/僅僅在該AS傳遞(如果沒有聯邦就等同於no-export參數)
R6:
route-policy COMM permit node 5
if-match acl 2006
apply community no-export-subconfed
#
route-policy COMM permit node 10
<R5>dis bgp routing-table 6.6.6.6

BGP local router ID : 10.1.35.5
Local AS number : 65535
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 6.6.6.6/32:
From: 66.1.1.1 (0.0.6.6)
Route Duration: 00h01m45s
Relay IP Nexthop: 10.1.56.6
Relay IP Out-Interface: Serial2/0/0
Original nexthop: 66.1.1.1
Qos information : 0x0
Community:no-export-subconfed
AS-path 60, origin igp, MED 0, pref-val 0, valid, external, best, select, active, pre 255, IGP cost 48
Not advertised to any peer yet //不更新給其他的成員as
結果是成員as 64512中不存在路由
需求:請在AS345中配置(不允許在as60配置),使得AS64512 得到該路由
團體屬性是一種需要配合使用的參數,具備一個破壞性的參數
route-policy NO permit node 10
apply community none //可以把所有團體屬性拿掉
新需求:
<R5>dis bgp routing-table 6.6.6.6

BGP local router ID : 10.1.35.5
Local AS number : 65535
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 6.6.6.6/32:
From: 66.1.1.1 (0.0.6.6)
Route Duration: 00h00m03s
Relay IP Nexthop: 10.1.56.6
Relay IP Out-Interface: Serial2/0/0
Original nexthop: 66.1.1.1
Qos information : 0x0
Community:<60:6>, no-export-subconfed
3.2 自定義的團體屬性
3.3 團體屬性列表應用和影響選路
團體屬性列表,用於去匹配團體屬性
[R1]ip community-filter 1 permit 60:6 //團體屬性列表命中某些團體屬性
route-policy XUANLU permit node 10
if-match community-filter 1
apply preferred-value 10 //針對團體屬性修改影響選路的參數
#
route-policy XUANLU permit node 20 //放行其他路由
[R1-route-policy]bgp 10
[R1-bgp]peer 15.15.15.15 route-policy XUANLU import //針對鄰居來影響選路
<R1>tracert 6.6.6.6
traceroute to 6.6.6.6(6.6.6.6), max hops: 30 ,packet length: 40,press CTRL_C to break
1 10.1.15.5 60 ms 40 ms 40 ms
2 10.1.56.6 50 ms 40 ms 50 ms
總結:
1).對某些路由自定團體屬性 2).別忘記向鄰居通告團體屬性,否則中斷了策略 3)應用 4)對團體屬性列表匹配的路由,通過路由策略影響選路
作業:
R6上產生的路由6.6.6.6自定義團體屬性60:6;
AS345的R4+R1建立ebgp鄰居
AS345的R5+SW3建立ebgp鄰居
R1上到達6.6.6.6通過高速的以太網轉發數據,其他路由不受影響

4.BGP的選路屬性和操作

乾頤堂軍哥HCIE課程10-BGP的路由聯邦實施以及團體屬性操控路由