1. 程式人生 > >乾頤堂軍哥HCIE12-BGP的對等體組和BGP的路由操控理論和實驗

乾頤堂軍哥HCIE12-BGP的對等體組和BGP的路由操控理論和實驗

1.3 繼承 gin face image maximum group 標準 med

BGP
技術分享圖片
1.對等體組
peer group
出/入方向策略需要一致
步驟:
定義peer組: group QYT internal
在組中添加內容,即命令或者策略
peer QYT connect-interface LoopBack0
peer QYT reflect-client
針對一個鄰居來調用peer組:peer 55.1.1.1 group QYT

bgp 345
group QYT internal
peer QYT connect-interface LoopBack0
peer 44.1.1.1 as-number 345
peer 44.1.1.1 group QYT
peer 55.1.1.1 as-number 345
peer 55.1.1.1 group QYT
#
ipv4-family unicast
undo synchronization
peer QYT enable
peer QYT reflect-client
peer 44.1.1.1 enable
peer 44.1.1.1 group QYT
peer 55.1.1.1 enable
peer 55.1.1.1 group QYT
2.屬性和路由控制
attribute
2大類4小類
通過策略來影響選路的實驗:
13條選路原則:
世界戀愛組織亞洲辦公室(World-PreVal,Love-localPref,O-sOurced local,Asia-Aspath,Office-orgin)
墓碑下的(MEML)M-MED,E-Ebgp,M-metric,L-Loadbalance
半獸人(ORC-->COI),C-Cluster list,O-Originator/RID,I-IP
O,建立時間更久的eBGP(華為不做為標準)
選路的前提:下一跳可達以及同步關閉
順序,靠前的原則已經選出了最優的路由,後邊的原則就不在生效
1)PreferValue
華為私有屬性,僅僅在本設備有意義。不能更新給任何鄰居設備,數值越大越優先,只能在入方向有效
[R3-bgp]peer 44.1.1.1 preferred-value 4 //從R4得到的路由的優先級值為4,會優選所有從R4更新來的路由,不能做到精細控制
推薦方式:
route-policy PRE permit node 10
if-match acl 2001
apply preferred-value 4
#
route-policy PRE permit node 20

[R3-acl-basic-2001]rule 5 permit source 1.1.1.1 0
[R3-bgp]peer 44.1.1.1 route-policy PRE import
<R3>dis bgp routing-table

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

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

*>i 1.1.1.1/32 44.1.1.1 0 100 4 10i

  • i 55.1.1.1 100 0 10i
    2)戀愛,本地優先級,local-preference(公認任意)
    僅僅在AS內部生效(local),不會更新出eBGP,默認值為100(你可能在表面上看不到這個值,從ebgp鄰居處得到的路由),取值越大越優先
    應用場景:AS內部的設備選取哪一個ASBR做為出口路由器
    default local-preference 104 //修改從該設備始發的iBGP路由的本地優先級屬性
    影響比較大
    需求:
    1.1.1.1 優選R4
    111.1.1.1 優選R5
    route-policy Local-Pre permit node 10
    if-match acl 2001
    apply local-preference 400
    #
    route-policy Local-Pre permit node 20
    [R4-bgp]peer 10.1.1.1 route-policy Local-Pre import //在ASBR設備上針對ebgp鄰居應用,修改本地優先級完畢之後的路由會更新給iBGP鄰居
    3)O,Sourced local(本設備生成的路由優先於從鄰居得到的路由)
    在前綴和掩碼一致的前提下,1.1.1.0/24(本設備聚合的)和1.1.1.0/24(本設備network的),此時都是本設備生成的路由,此時聚合的路由優先級非聚合的路由!

    network 1.1.1.0 255.255.255.0 //此時network優先於import
    import-route static

4)as-path列表比較短的優先
影響比較大
[R5-route-policy]apply as-path 10 10 additive //額外附加兩個as號碼10 10
route-policy AS-PATH permit node 10
apply as-path 345 33 overwrite //改寫原有的AS path

忽略AS-path的選路
[R3-bgp]bestroute as-path-ignore
選路在本設備發生,水平分割原則依舊有效!
5)Office-Origin code
i>e>?
i:network/aggregate產生的路由
e:EGP方式(淘汰了)
?:引入的路由
route-policy Origin permit node 10
if-match acl 2001
apply origin incomplete
#
route-policy Origin permit node 20

[R3-bgp]peer 44.1.1.1 route-policy Origin import
6) MED(多出口分離器)
被看做BGP的度量值metric,數值越小越優先
MED可以繼承自IGP,也可以自定義
在eBGP鄰居間應用MED值,影響對端AS如何發送數據報到達本AS
route-policy MED permit node 10
if-match acl 2001
apply cost 10
#
route-policy MED permit node 20
if-match acl 2003
apply cost 3
peer 10.1.15.5 route-policy MED export
另外一個設備的調用:
route-policy MED permit node 10
if-match acl 2001
apply cost 3
#
route-policy MED permit node 20
if-match acl 2003
apply cost 10
[R1-bgp]peer 10.1.1.4 route-policy MED export
結果:
<R3>dis bgp routing-table

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

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

>i 1.1.1.1/32 44.1.1.1 3 100 0 10i
>i 6.6.6.0/28 55.1.1.1 100 0 60i
>i 6.6.6.6/32 55.1.1.1 0 100 0 60i
>i 111.1.1.1/32 55.1.1.1 3 100 0 10i
*>i 192.168.1.1/32 55.1.1.1 0 100 0 60i
7)eBGP由於iBGP
優先級,IBGP和EBGP優先級都為255
8)M,Metric
到達鄰居(適應於IBGP和EBGP)的更新源地址的IGP的度量值較小的優選
9)L,load-balance
如果前8個選路原則選不出最優的路由,可以實施負載均衡,指dis ip rou 到達同一個路由有多個下一跳地址
[R3-bgp]maximum load-balancing ?
INTEGER<1-8> Specify maximum equal cost routes //both,對ebgp和iBGP路由同時生效
ebgp EBGP routes as equal cost route //eBGP的負載,僅僅對eBGP有效
ibgp IBGP routes as equal cost route //iBGP的負載,僅僅對iBGP路由有效
[R3-bgp]dis ip rou pro bgp
Route Flags: R - relay, D - download to fib

Public routing table : BGP
Destinations : 7 Routes : 11

BGP routing table status : <Active>
Destinations : 7 Routes : 11

Destination/Mask Proto Pre Cost Flags NextHop Interface

    1.1.1.1/32  IBGP    255  0          RD   44.1.1.1        Serial2/0/0
                IBGP    255  0          RD   55.1.1.1        GigabitEthernet0/0/0

10)COI(n)
C,擁有較短的簇列表的會被優選
RID較小的或者起源ID較小的被優選
[R5-bgp]router-id 4.4.4.3
peer後邊較小的地址的被優選
作業:
使用MED,在AS10中配置,滿足如下需求:
<R3>dis bgp routing-table

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

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

>i 1.1.1.1/32 44.1.1.1 3 100 0 10i
>i 6.6.6.0/28 55.1.1.1 100 0 60i
>i 6.6.6.6/32 55.1.1.1 0 100 0 60i
>i 111.1.1.1/32 55.1.1.1 3 100 0 10i
*>i 192.168.1.1/32 55.1.1.1 0 100 0 60i
3.過濾
團體屬性
前綴列表:
ip ip-prefix 44 index 10 deny 192.168.1.1 32
ip ip-prefix 44 index 20 permit 0.0.0.0 0 less-equal 32
[R3-bgp]peer QYT ip-prefix 44 export
route-policy
as-path list (使用了正則表達式)

乾頤堂軍哥HCIE12-BGP的對等體組和BGP的路由操控理論和實驗