天天看點

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

BGP

乾頤堂軍哥HCIE12-BGP的對等體組和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 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 44.1.1.1 enable

peer 55.1.1.1 enable

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 

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 

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 

apply cost 3 

route-policy MED permit node 20 

if-match acl 2003 

[R1-bgp]peer 10.1.1.4 route-policy MED export 

結果:

Total Number of Routes: 5

Public routing table : BGP

Destinations : 7 Routes : 11

BGP routing table status : <Active>

Destination/Mask Proto Pre Cost Flags NextHop Interface

10)COI(n)

C,擁有較短的簇清單的會被優選

RID較小的或者起源ID較小的被優選

[R5-bgp]router-id 4.4.4.3

peer後邊較小的位址的被優選

作業:

使用MED,在AS10中配置,滿足如下需求:

>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 (使用了正規表達式)

本文轉自EnderJoe 51CTO部落格,原文連結:http://blog.51cto.com/enderjoe/2063193

繼續閱讀