1. 程式人生 > >乾頤堂軍哥HCIE9-解決BGP路由黑洞、聚合的各種參數以及RR基礎

乾頤堂軍哥HCIE9-解決BGP路由黑洞、聚合的各種參數以及RR基礎

blog none 全部 aso 數據 gre let 產生 參數

本技術文章討論BGP的路由黑洞解決方案、BGP聚合,即減少路由條目數的技術
技術分享圖片
1.BGP路由黑洞
1.1 解決路由黑洞問題1
某些AS內的設備沒有運行BGP(R3),那麽它會缺少路由(2.2.2.2/6.6.6.6),由於IP報文是逐跳轉發的,報文到達R3,R3只能丟棄報文
解決方案:
1)BGP的全互聯(full-mesh)確實可以解決路由黑洞問題,同時帶來了鄰居過多,TCP會話多拖,沒必要的路由更新過多,拍錯困難等問題
完成全互聯配置:
bgp 345
peer 33.1.1.1 as-number 345
peer 44.1.1.1 as-number 345
peer 44.1.1.1 connect-interface LoopBack0
peer 66.1.1.1 as-number 60
peer 66.1.1.1 ebgp-max-hop 2
peer 66.1.1.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 5.5.5.5 255.255.255.255
network 55.1.1.0 255.255.255.0
network 55.1.1.1 255.255.255.255
peer 33.1.1.1 enable
peer 33.1.1.1 next-hop-local
peer 44.1.1.1 enable
peer 44.1.1.1 next-hop-local
peer 66.1.1.1 enable
2)BGP引入到IGP(困難重重)
<R5>dis ip routing-table protocol bgp
Route Flags: R - relay, D - download to fib

Public routing table : BGP
Destinations : 3 Routes : 3

BGP routing table status : <Active>
Destinations : 3 Routes : 3

Destination/Mask Proto Pre Cost Flags NextHop Interface

    2.2.2.2/32  IBGP    255  0          RD   44.1.1.1        Serial1/0/0
    6.6.6.6/32  EBGP    255  0          RD   66.1.1.1        Serial2/0/0
   22.1.1.1/32  IBGP    255  0          RD   44.1.1.1        Serial1/0/0

<R4>dis ip routing-table protocol bgp
Route Flags: R - relay, D - download to fib

Public routing table : BGP
Destinations : 4 Routes : 4

BGP routing table status : <Active>
Destinations : 3 Routes : 3

Destination/Mask Proto Pre Cost Flags NextHop Interface

    2.2.2.2/32  EBGP    255  0           D   10.1.24.2       GigabitEthernet0/0/1
    5.5.5.5/32  IBGP    255  0          RD   55.1.1.1        Serial1/0/0
    6.6.6.6/32  IBGP    255  0          RD   55.1.1.1        Serial1/0/0

配置:
R4和R5
ospf 1 router-id 5.5.5.5
import-route bgp //現實網絡,極有可能需要路由策略以及註意iBGP的環境,默認情況下只能把eBGP路由引入到IGP;iBGP不能引入到IGP(基於環路考慮)
[R5-ospf-1]import-route bgp permit-ibgp //在OSPF進程下允許把iBGP引入引入到OSPF,產生路由環路可能性很大
<R3>dis ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib

Public routing table : OSPF
Destinations : 14 Routes : 14

OSPF routing table status : <Active>
Destinations : 14 Routes : 14

Destination/Mask Proto Pre Cost Flags NextHop Interface

     2.2.2.2/32  O_ASE   150  1           D   10.1.35.5       GigabitEthernet0/0/0

//R3的下一跳是35.5

3)MPLS 環境
標簽轉發
1.2 BGP的同步概念
同步的目的是為了在不做全互聯的前提下解決BGP路由黑洞
但本身是一種過時的技術(所以華為設備無法開啟BGP同步)
同步是IBGP和IGP路由同步,如果沒有實現同步,那麽結果是路由不更新給eBGP
本身
此時iBGP得到了11.1.1.1的路由,但是IGP沒有得到,此時同步沒有完成,但是卻開啟了同步命令
router bgp 200
synchronization
結果是什麽?結果是由於該路由不是最優的,所以不會更新給eBGP鄰居R5!
1--(2--3--4)--5
2.BGP的路由提高(產生路由)
BGP的路由如何產生:
1)network命令,在bgp中不用於建立鄰居,只是產生路由。BGP可以network其他協議產生的路由(OSPF、rip、isis、靜態、直連),這個位置有一個屬性:origin屬性為i;聚合方式也可以產生路由,起源屬性也是i
2)EGP形式,起源屬性為e
3)引入路由:import,起源屬性為?(incomplete)
3.聚合
3.1 自動聚合
僅僅在DV協議才存在
僅僅對引入的(import)路由有效
[R5]bgp 345
[R5-bgp]
[R5-bgp]su
[R5-bgp]summary au
[R5-bgp]summary automatic
Info: Automatic summarization is valid only for the routes imported through the import-route command.
<R6>dis bgp routing-table 66.0.0.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 66.0.0.0/8:
From: 55.1.1.1 (10.1.35.5)
Route Duration: 00h02m01s
Relay IP Nexthop: 10.1.56.5
Relay IP Out-Interface: Serial2/0/0
Original nexthop: 55.1.1.1
Qos information : 0x0
AS-path 345, origin incomplete, pref-val 0, valid, external, best, select, active, pre 255, IGP cost 48
Aggregator: AS 345, Aggregator ID 10.1.35.5
3.2 增加了一種手動聚合方式
利用BGP的network命令,手工產生一條匯總後的靜態的匯總路由,然後再通告該路由
6.6.6.6 0000,0110
6.6.6.9 0000,1001
6.6.6.0 /28
[R6]ip route-static 6.6.6.0 28 NULL 0 //空接口,一個路由黑洞接口,所有到達6.6.6.0/28的數據都將被丟棄進空接口,否則將會造成帶寬的浪費
[R6]bgp 60
[R6-bgp]network 6.6.6.0 28 //僅僅通告匯總後的靜態路由,去掉明細路由,否則路由條目增多的
<R5>display bgp routing-table 6.6.6.0

BGP local router ID : 10.1.35.5
Local AS number : 345
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 6.6.6.0/28:
From: 66.1.1.1 (0.0.6.6)
Route Duration: 00h06m34s
Relay IP Nexthop: 10.1.56.6
Relay IP Out-Interface: Serial2/0/0
Original nexthop: 66.1.1.1
Qos information : 0x0
AS-path 60, origin igp, MED 0, pref-val 0, valid, external, best, select, active, pre 255, IGP cost 48
Advertised to such 2 peers:
44.1.1.1
33.1.1.1
3.3 專門的AGGREGATE
聚合的前提是BGP表中存在明細路由
3.3.1 直接實施,沒有任何參數
[R6-bgp]aggregate 6.6.6.0 28 //會生成一條聚合路由,但並不會抑制明細路由
<R5>dis bgp routing-table

BGP Local router ID is 10.1.35.5
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete

Total Number of Routes: 21
Network NextHop MED LocPrf PrefVal Path/Ogn

>i 2.2.2.2/32 44.1.1.1 0 100 0 20i
> 5.5.5.5/32 0.0.0.0 0 0 i
> 6.6.6.0/28 66.1.1.1 0 60i
> 6.6.6.6/32 66.1.1.1 0 0 60i
*> 6.6.6.9/32 66.1.1.1 0 0 60i
3.3.2 抑制明細路由,僅僅向鄰居公告匯總
[R6-bgp]aggregate 6.6.6.0 28 detail-suppressed
<R5>dis bgp routing-table

BGP Local router ID is 10.1.35.5
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete

Total Number of Routes: 19
Network NextHop MED LocPrf PrefVal Path/Ogn

>i 2.2.2.2/32 44.1.1.1 0 100 0 20i
> 5.5.5.5/32 0.0.0.0 0 0 i
> 6.6.6.0/28 66.1.1.1 0 60i
> 10.1.1.0/24 0.0.0.0 0 0 ?
[R6-bgp]dis bgp rou

BGP Local router ID is 0.0.6.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: 20
Network NextHop MED LocPrf PrefVal Path/Ogn

> 2.2.2.2/32 55.1.1.1 0 345 20i
> 5.5.5.5/32 55.1.1.1 0 0 345i
*> 6.6.6.0/28 127.0.0.1 0 i
s> 6.6.6.6/32 0.0.0.0 0 0 i
s> 6.6.6.9/32 0.0.0.0 0 0 i //s代表被抑制的,即沒有更新給鄰居的路由
R5聚合後
<R2>dis bgp routing-table 6.6.6.0

BGP local router ID : 10.1.24.2
Local AS number : 20
Paths: 1 available, 1 best, 1 select
BGP routing table entry information of 6.6.6.0/28:
From: 10.1.24.4 (4.4.4.4)
Route Duration: 00h00m09s
Direct Out-interface: GigabitEthernet0/0/2
Original nexthop: 10.1.24.4
Qos information : 0x0
AS-path 345, origin igp, pref-val 0, valid, external, best, select, active, pre 255
Aggregator: AS 345, Aggregator ID 10.1.35.5, Atomic-aggregate //在AS345的R5聚合後丟失了as屬性或者團體屬性
3.3.3
關於聚合之後的屬性可能會改變
eBGP的防環:如果在收到的bgp的as-path屬性中包含和自身相同的As號碼,則丟棄該路由
[R5-bgp]aggregate 6.6.6.0 255.255.255.240 detail-suppressed as-set //聚合後依舊攜帶原有的as集合的參數,避免環路的發生以及次優的轉發路徑
Jan 13 2018 14:46:27.729.1-08:00 R6 RM/6/RMDEBUG:
BGP.Public: 55.1.1.1 MSG ignored : Looping in ASPATH value,
while recv UPDATE .

<R6>
Jan 13 2018 14:46:27.729.2-08:00 R6 RM/6/RMDEBUG:
BGP: routes in update message need to be processed as withdrawn message due to reason mentioned above.

<R6>
Jan 13 2018 14:46:27.729.3-08:00 R6 RM/6/RMDEBUG:
BGP.Public: Recv UPDATE from 55.1.1.1 with following destinations :

    Update message length : 66
    MP_reach  : AFI/SAFI  1/1 
    Origin    : IGP 
    AS Path   : 345 60 
    Next Hop  : 55.1.1.1 
    BGP.Public: Recv UPDATE(Withdraw) MSG from 55.1.1.1 with following destinations :

    6.6.6.0/28,

需求:
在R5上完成聚合,不能看到明細路由,R2上得到的路由的as-path為345 60

Atomic_Aggregate:標識發生了路徑信息的丟失。生成的聚合路由帶Atomic-aggregate屬性,並且不能攜帶原具體路由的團體屬性。
Aggregator:標識路徑信息丟失發生的位置

3.3.4 抑制部分明細,放行匯總
[R6-bgp]aggregate 6.6.6.0 28 suppress-policy SUPPRESS //使用SUPPRESS這個路由策略來命中路由,被聚合中的suppress-policy調用,命中的路由抑制,其他路由放行

acl number 2000
rule 5 permit source 6.6.6.9 0
route-policy SUPPRESS permit node 5
if-match acl 2000
[R6]dis bgp routing-table

BGP Local router ID is 0.0.6.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: 20
Network NextHop MED LocPrf PrefVal Path/Ogn

> 2.2.2.2/32 55.1.1.1 0 345 20i
> 5.5.5.5/32 55.1.1.1 0 0 345i
> 6.6.6.0/28 127.0.0.1 0 i
> 6.6.6.6/32 0.0.0.0 0 0 i
s> 6.6.6.9/32 0.0.0.0 0 0 i //被抑制在本地的路由
3.3.4
聚合後的起源屬性是?
[R6-bgp]aggregate 6.6.6.0 255.255.255.240 suppress-policy SUPPRESS attribute-policy ATTRIBUTE //對聚合後的路由修改起源屬性為egp
route-policy ATTRIBUTE permit node 10
apply origin egp 123
驗證結果:
<R5>dis bgp routing-table

BGP Local router ID is 10.1.35.5
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete

Total Number of Routes: 20
Network NextHop MED LocPrf PrefVal Path/Ogn

>i 2.2.2.2/32 44.1.1.1 0 100 0 20i
> 5.5.5.5/32 0.0.0.0 0 0 i
> 6.6.6.0/28 66.1.1.1 0 60 123e //成功
> 6.6.6.6/32 66.1.1.1 0 0 60i
聚合後並不能改變所有屬性,常見可以修改的屬性:起源和團體屬性
——————————————————————————————
SW1和R3建立ebgp鄰居,同時聚合一條6.0.0.0的路由
[R4-route-policy]dis cu conf bgp
[V200R003C00]
#
bgp 345
peer 10.1.24.2 as-number 20
peer 33.1.1.1 as-number 345
peer 55.1.1.1 as-number 345
peer 55.1.1.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
aggregate 6.0.0.0 255.0.0.0 as-set detail-suppressed origin-policy ORIGIN //可以更加明晰的表明某些路由起源自哪些AS
route-policy ORIGIN permit node 10
if-match acl 2000
[R4-route-policy]dis acl all
Total quantity of nonempty ACL number is 2

Basic ACL 2000, 2 rules
Acl‘s step is 5
rule 5 permit source 6.6.6.10 0 (1 matches)
rule 10 deny (2 matches)
驗證結果:
<R2>dis bgp routing-table

BGP Local router ID is 10.1.24.2
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete

Total Number of Routes: 21
Network NextHop MED LocPrf PrefVal Path/Ogn

> 2.2.2.2/32 0.0.0.0 0 0 i
> 5.5.5.5/32 10.1.24.4 0 345i
> 6.0.0.0 10.1.24.4 0 345 30i
> 6.6.6.0/28 10.1.24.4 0 345 60 123e
*> 6.6.6.6/32 10.1.24.4 0 345 60i

4.RR和聯邦
應用場景都是管理大型BGP域的重要的技術,設計理念不同:RR是大面積的修改了iBGP的防環規則;聯邦依舊遵循iBGP的防環規則
4.1 實施和RR的規則
角色:1)RR 2)RR的客戶端 3)非客戶端
bgp 345
peer 10.1.30.10 as-number 30
peer 44.1.1.1 as-number 345
peer 44.1.1.1 connect-interface LoopBack0
peer 55.1.1.1 as-number 345
peer 55.1.1.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
peer 10.1.30.10 enable
peer 44.1.1.1 enable
peer 44.1.1.1 reflect-client //指定R4和R5為RR的客戶端,意味著R3成為RR
peer 55.1.1.1 enable
peer 55.1.1.1 reflect-client

[R5]bgp 345
[R5-bgp]un peer 44.1.1.1 //不在需要全部互聯
4.2 RR環境下的防環規則
兩個新的屬性:起源者Originator和簇ID,Cluster list
切記:非非(非客戶端之間)不傳
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 //更新給非客戶端
4.3 層次化的RR

5.團體屬性

乾頤堂軍哥HCIE9-解決BGP路由黑洞、聚合的各種參數以及RR基礎