BGP路由協議


 一、BGP(Border Gateway Protocol)邊界網關協議

  1.BGP特點:

    可靠性:1、利用tcp建立可靠的連接 2、精確的路由選擇信息(防環)

    穩定性:1、通過計時器來防止接口的flapping,在cisco的ios中,外部bgp路由為30秒。

        2、可以跟蹤指定的路由,根據他的震盪的歷史,對其進行路由的衰減(懲罰)。

    可擴展性:1、對等體(peer)【鄰居】的數量,數百個會話;2、路由的數量,40萬條以上的路由條目

    靈活性:1、豐富的路由屬性;2、多種策略的廣利(出、入兩個方向的管理,基於路由的管理)

  2.BGP鄰居

    IBGP鄰居:指在相同AS內,建立BGP鄰居,鄰居之間可以不必直連。當傳遞路由給IBGP鄰居時,默認下一跳不變。

      IBGP的水平分割:從IBGP鄰居收到的路由,不會再傳遞給IBGP鄰居。

    EBGP鄰居:指在不同的AS之間建立鄰居關系,一般是通過直連接口創建,也可以通過非直連的接口建立。當傳遞路由給EBGP鄰居時默認下一跳改為自己。

  3.基本命令

R2(config)#router bgp 100                                  起BGP協議,設置AS號
R2(config-router)#bgp router-id 2.2.2.2 設置router-id號
R2(config-router)#neighbor 1.1.12.1 remote-as 100      指定對方屬於哪一個AS,所指的IP地址,必須在IGBP中可達
R2(config-router)#neighbor 1.1.12.1 remote-as 100 backdoor 指定對方屬於哪一個AS,管理距離按照200計算
R2(config)#show ip bgp summary                             顯示鄰居關系,state字段顯示為數字表示建立成功,數字代表從該鄰居獲得的路由數
R2(config)#show tcp brief 顯示端口連接信息,展示誰主動打開tcp連接的

直連建立鄰居關系
neighbor x.x.x.x remote-as 100

非直連建立鄰居關系
neighbor x.x.x.x remote-as 100
neighbor x.x.x.x update-source interface 修改源端口,通過源檢測

注意:

  1.默認路由是不能主動發起TCP連接請求的,但是可以回應對端的TCP連接請求,靜態路由會主動發起tcp請求。

  2.主動發起TCP連接請求的一方必須用對方Neighbor所指定的IP地址為源地址發出TCP連接請求,如果對方沒有使用此地址,這個TCP請求被拒絕。(TCP連接源檢測)

R1(config-router)#neighbor 10.10.2.2 disable-connected-check    關閉直連檢測
R2(config-router)#neighbor 10.10.1.1 ebgp-multihop 200 修改TTL值,通過直連檢測

EGBP:直連建立鄰居關系
neighbor x.x.x.x remote-as 200

直連回環口建立EBGP鄰居
neighbor x.x.x.x remote-as 200
neighbor x.x.x.x update-source interface
neighbor 2.2.2.2 ebgp-multihop <N>TTL TTL>1 --忽略直連檢測
neighbor 2.2.2.2 disable-connected-check //或者,關閉直連檢測

非直連建立EGBP鄰居
neighbor x.x.x.x update-source interface
neighbor 2.2.2.2 ebgp-multihop <N>TTL

  4.NO-autosummary

    Network含義: network 后面的網段和掩碼必須和路由表中的條目精確匹配才能引入。

    Redistribute:重分布明細路由進入BGP。

  5.Autosummary

    netowrk含義:network后面的網段和掩碼必須和路由表中明細路由的主類路由匹配才能引入。

    Redistribute:重分布主類路由進入BGP。

  6.在BGP表中的路由優化之后的2個動作。

    1.向路由表提交這條最優的BGP路由;

    2.向BGP的peer鄰居發送包含這條BGP最優路由的更新。

  7.BGP路由最優的條件

    1.入向策略允許的路由

    2.下一跳可達(本地優化)

    3.路徑選擇(路徑優化),若有多條路徑去往相同的目的網段,選擇一條最優的路由

    4.同步(默認關閉)

  8.路由黑洞

    1.同步是早期,BGP為解決路由黑洞的一種方法。

    2.開啟同步:針對IBGP路由,從IBGP鄰居收到的路由,要求路由表中也得有此路由。

R4(config-router)#neighbor 2.2.2.2 next-hop-self         傳遞路由下一跳改為自己,解決IBGPh傳路由,不改變下一跳,網絡不可達問題
R2(config)#router ospf 100
R2(config-router)#redistribute bgp 234 subnets ospf路由重分布到bgp
R2(config-router)#redistribute connected subnets 直連路由重分布
R3#show ip bgp neighbors 4.4.4.4 advertised-routes 查看R3向4.4.4.4這個鄰居通告了哪些路由

  9.聯邦:將大的AS划分成若干個小AS,小AS之間是EBGP關系。

    優點:在相對豐富的策略

    缺點:由於只能小於2個路由相連

R3(config-router)#bgp confederation identifier 234       聲明是哪個大的AS下面
R3(config-router)#bgp confederation peers 64544 聯邦里面的EBGP需要互相指peers

             IBGP鄰居,聯邦的IBGP,聯邦的EBGP鄰居之間傳遞路由,下一跳不變。

  10.路由反射器

    1.從RR的一個客戶端傳遞過來的一條路由:RR會傳遞給我的另外一個反射簇的客戶端,非客戶端,也會傳遞給我的另一個EBGP鄰居。

    2.從RR的一個非客戶端傳遞過來的一條路由:RR會傳遞給我的另外一個反射簇的客戶端,也會傳遞給我的另一個EBGP鄰居,但不會傳遞給我的另一個非客戶端。

    3.路由反射器打破了水平分割,通過Originator,Cluster List值防環。

R4(config-router)#neighbor 10.10.2.2 route-reflector-client   指定反射客戶端

  11.第三方下一跳 

         

    1.R1與R2直連建鄰居,R2和R3直連建立鄰居,R133.3.3.0路由下一跳,指向R3。

    2.R1與R2直連建鄰居,R2和R3Loopback建立鄰居,R133.3.3.0路由下一跳,指向R3。

    3.R1與R2Loopback建鄰居,R2和R3直連建立鄰居,R133.3.3.0路由下一跳,指向R2。

    3.R1與R2Loopback建鄰居,R2和R3Loopback建立鄰居,R133.3.3.0路由下一跳,指向R2。

   結論:R1與R2直連建立鄰居,R2通過遞歸查詢,下一跳為192.168.123.3 ,與建立鄰居neighbor 192.168.123.1 為同一網段,R2認為R1和R3也是通的,所以認為R1去R3不用通過自己,稱下一跳優化。

     注意:RIP與EIGRP也存在第三方下一跳,只不過EIGRP是關閉的。

   BGP的第三方下一跳:收到BGP路由的下一跳(遞歸完成的下一跳)與Nei地址是在同一個網段,保持下一跳地址不變;不在同一個網段,則正常改變下一跳。

   特殊:如果路由的下一跳(遞歸完的下一跳)與nei地址相同,改變下一跳。

二、BGP的十三條選路原則

  

  1、選路第一條:

    Weight值:越大越好;cisco私有的;本地有效;只能在in方向做;默認值0(接收到的),32768(發出路由方);修改weight的兩種方法: nei x.x.x.x weight y,route-map。

neighbor 22.1.1.1 weight 10                      針對所有22.1.1.1傳給的路由都修改weight值

R1(config)#access-list 1 permit 77.1.1.0 抓取路由
R1(config-route-map)#match ip address 1
R1(config-route-map)#set weight 11 設置weigth值
R1(config)#route-map W permit 999 放行所有

  2、選路第二條:

    local-preference:優選最大;缺省值100;只能在IBGP傳遞,不能在EBGP傳遞;從EBGP學到的BGP條目,LP為100,可以通過bgp default local-preference修改;可以在in/out方向。  

R1(config-router)#bgp default local-preference 99    修改默認的local值
R1(config-router)#do clear ip bgp * so 清空路由

R1(config)#route-map L
R1(config-route-map)#match ip address 1
R1(config-route-map)#set local-preference 101
R1(config)#route-map L permit 999
R1(config)#router  bgp 100
R1(config-router)#neighbor 22.1.1.1 route-map L in

   3、選路第三條

    本地起源:從本地注入BGP條目的方法:network   / redistrbution  /agg

R2(config)#ip route 77.1.1.0 255.255.255.0 null 0       R2上偽造一條路由
R2(config)#router bgp 100
R2(config-router)#network 77.1.1.0 mask 255.255.255.0
R2(config)#router bgp 100
R2(config-router)#neighbor 27.1.1.7 weight 32768
R2(config-router)#do clear ip bgp * so

  4、選路第四條

    AS-path:優選最短的AS-path;EBGP鄰居作用;bgp bestpath as-path ignore忽略這條選路原則(隱藏命令)

    Last-as參數:表示離這個AS最近的AS,重復的次數

R2(config)#access-list 1 permit 22.1.1.0
R2(config)#route-map AS-P
R2(config-route-map)#match ip address 1
R2(config-route-map)#set as-path prepend 2 3
R2(config)#route-map AS-P permit 999
R2(config)#router bgp 100
R2(config-router)#neighbor 27.1.1.7 route-map AS-P out 出去的方向
R2(config-router)#do clear ip bgp * so ou

R3(config)#access-list 1 permit 22.1.1.0
R3(config)#route-map AS-P
R3(config-route-map)#match ip address 1
R3(config-route-map)#set as-path prepend 4 5 6
R3(config-route-map)#set as-path prepend last-as 2 以最后一個as重復兩次
R3(config)#route-map AS-P permit 999
R3(config)#router bgp 200
R3(config-router)#neighbor 17.1.1.1 route-map AS-P in
R3(config-router)#do clear ip bgp * so in

   5、選路第五條:起源屬性(起源代碼)

    Origin :-i > e > ?   ;   - in / out

R3(config)#access-list 1 permit 22.1.1.0
R3(config)#route-map O
R3(config-route-map)#match ip address 1
R3(config-route-map)#set origin incomplete   設置成重分布(?)
R3(config)#route-map O permit 999
R3(config)#router bgp 200
R3(config-router)#neighbor 27.1.1.2 route-map O in
R3#clear ip bgp * so

   6、選路第六條

    MED:優選最小;唯一一個只影響相鄰AS選路屬性;告訴EBGP鄰居怎么進入本AS;從EBGP學習到BGP條目攜帶的MED可以傳給其他IBGP;

    從IBGP學習到的BGP路由條目的MED為0或者其他值,缺省不會傳給EBGP鄰居,顯示為空;匯總方式生成的BGP條目,MED值為空。

    Bgp bestpath med missing-med-worst 顯示MED,並且進行MED選路原則的比較,如果不顯示MED,MED為空

    第一個AS號相同才會比較MED,從左邊開始數

    bgp always-conpare-med打破AS相同的限制

    bgp deterministic-med是指把路由過來的MED值進行分組,同一個AS的分組,其他的AS的分一組,先比較同一個AS的MED值,再和其他的AS的MED值比較路由器那個最小的R-ID。

    bgp bestpath as-path ignore(隱含命令)

R1(config)#router bgp 100
R1(config-router)#network 11.1.1.0 mask 255.255.255.0                     明細路由
R1(config-router)#aggregate-address 11.1.0.0 255.255.0.0                  匯總路由
R1(config-router)#bgp bestpath med missing-as-worst med值為空,自動生成默認值

R1(config)#route-map MED
R1(config-route-map)#match ip address 1
R1(config-route-map)#set metric 12
R1(config)#route-map MED permit 999
R1(config)#router bgp 100
R1(config-router)#neighbor 17.1.1.7 route-map MED in

    7、選路第七條

    EBGP優於IBGP學過來的路由:EBGP 20 ;IBGP 200 

    EBGP > 聯邦EBGP > IBGP

    8、選路第八條

    優選對BGP下一條具有最低IGP度量值的路徑

             

R3#clear bgp ipv4 unicast 11.1.1.1                        清除單個鄰居
R3(config)#int e0/2
R3(config-if)#ip ospf cost 1 修改cost值為1

  9、選路第九條

     BGP等價負載均衡:缺省未打開,打開就實現負載+ ;maxi-path 2

     非等價負載均衡配置    

      bgp dmzlink-bw(全局)

      nei xxx dmzlink-bw (鄰居)

  10、選路第十條

    最老的EBGP鄰居:最老的EBGP鄰居意味着是最穩定的,或者說是路由學習到時間最老的,不是鄰居最久的。 

 使能bgp bestpath compare-routerid,跳過第十條,最小的

  11、選路第十一條

    最低的IBGP/EBGP router-id

    EBGP可以通過上一個實驗看到(不看10條)

    IBGP是比較Originator ID (就是第一跳路由器的router-id)

           

  有RR情況下,Originator是router-id,如果沒有,括號里就是router-id。

R1(config)#router bgp 100
R1(config-router)#bgp router-id 1.1.1.1   手動指定router-id

  12、選路第十二條

    Cluster_list 長度短的;IBGP中用到;當一個路由從多個RR(路由反射)收到,選擇最短的cluster-list。

              

R5(config)#router bgp 100
R5(config-router)#neighbor IBGP peer-group   創建一個盒子
R5(config-router)#neighbor IBGP remote-as 100         把常用的命令放進盒子里面
R5(config-router)#neighbor IBGP update-source loopback 0 把常用的命令放進盒子
R5(config-router)#neighbor IBGP next-hop-self
R5(config-router)#neighbor 4.4.4.4 peer-group IBGP 調用盒子

   13、選路第十三條

    最低的鄰居地址的路徑;最小的建立鄰居的地址,是update-soure接口;IBGP鄰居。

              

 三、BGP路由過濾

  1、拓撲圖

  

   2、as-path過濾:不能基於掩碼的控制

.       任意簡單的字符,包括字符
*      零次或者多次
+      一次或者多次
? 零次或一次出現
^      從什么開始
$      從什么結束
- 匹配任意東西(包含空格,開始,結束,空間,選項卡,逗號)
\      
[]
|

^$ 起源於本AS的
_300$ 表示起源於300的路由
^100_    從鄰居as100來的
^100$ 起源於AS100的,且從鄰居as100來的
_100_ 起源於AS100的;從鄰居AS100來的;穿過AS100來的
^[0-9]+$ 任何起源於鄰居AS的
.* 所有
^([0-9]+)(_\1)*$ 以任意數值標記的AS號以及重復出現的

 例子:

Router(config)#ip as-path access-list 10 deny _12$             過濾掉起源AS2的
Router(config)#ip as-path access-list 10 permit .*        允許所有
Router(config-router)#neighbor 44.1.1.4 filter-list 10 in 在和R4建立鄰居的時候,in方向調用

R4(config)#ip as-path access-list 10 deny ^$ 起源本地的AS
R4(config)#ip as-path access-list 10 permit .*          允許所有
R4(config)#router bgp 345                      
R4(config-router)#neighbor 44.1.1.6 filter-list 10 out 在和R6建立鄰居的時候,out方向調用

  3、Prefix-list:可以基於掩碼的控制

Router(config)#ip prefix-list PW permit 11.1.1.0/x  ge y le z
Router(config)#ip prefix-list abc deny 11.1.3.0/24
Router(config)#ip prefix-list abc permit 0.0.0.0/0 le 32
neighbor 46.1.1.4 prefix-list abc in

    x<y<z

    1、當沒有ge,掩碼范圍最小值跟前綴相同

    2、當沒有ge,沒有指定le,le=32

    3、當沒有ge和le,ge和le與前綴相同

   4、BGP路由過濾-----ORF

    假設和ISP路由互聯,ISP上有很多路由前綴,但是只有部分是我想要的,此時要想讓ISP路由器只發送我所需要的路由前綴過來就要用到ORF技術

Router(config)#neighbor x.x.x.x capability orf prefix-list both
Router#show ip bgp neighbors 46.1.1.6 advertised-routes 查看我發給46.1.1.6的所有路由

   5、BGP路由過濾-----Policy list

     BGP route-map policy list

     BGP route-map continue

Router(config)#ip policy-list test deny
Router(config)#route-map test
Router(config-route-map)#match policy-list test

                         

   四、BGP優化

    1、PA配置步驟

      定義要統計的感興趣流量並設置流量suoyin  

      Communitu-list 、AS-PATH 或者AS號等參數都可以用於抓取感興趣流量

      在route-map中匹配感興趣流量

ip community-list 30 permit 300:300
route-map PA permit 10
match community-list 30
set traffic-index 3

       2、將IP流量歸類

          在BGP進程中使用table-map關鍵字關聯上面定義好的route-map

        BGP將基於route-map中定義的規則對路由表中路由進行歸類

       其實就是把感興趣流量歸類到taffic-index中。

        例如:

router bap 12
table-map PA

      3、在接口上激活BGP PA  

bgp-policy accounting [input | output]

      4、查看BGP PA的統計結果

show cef interface policy-statistics

       5、提高收斂

        全internet收斂時間大於1小時

        單個ISP要求在半個小時完成收斂

        判斷BGP收斂完成的標准(完成收到路由、版本號一致/I/O)

BGP scanner process 對大量的路由掃描,如果掃描周期短,可導致高的CPU利用率
BGP router process 每秒運行一次,檢查是否需要工作

Router(config)#router  bgp 66
Router(config-router)#bgp scan-time 30 修改,默認為30秒

       6、優雅重啟

        控制層面重啟,數據層面繼續保持轉發的技術

Router(config)#router bgp 66
Router(config-router)#bgp log-neighbor-changes 記錄鄰居的上/下和重置原因
Router(config-router)#bgp graceful-restart restart-time 120 設置重啟所需要的最大時間
Router(config-router)#bgp graceful-restart stalepath-time 360 設置保持重新啟動peer的陳舊路徑的最大時間
Router(config-router)#bgp graceful-restart

      7、控制收到路由數量

Router(config-router)#neighbor 46.1.1.4 maximum-prefix 100             從該對等點接受的前綴的最大數目,超過就告警
Router(config-router)#neighbor 46.1.1.4 maximum-prefix 100 restart     設置超過100條,超過限制后重新啟動bgp連接
Router(config-router)#neighbor 46.1.1.4 maximum-prefix 100 warning-only 僅當超過限制時發出警告消息

      8、解決路由不停的翻滾問題-dampening

        每一次EBGP路由的flap,都會給1000點的懲罰值

        懲罰值按照指數衰減法

        當懲罰值超過抑制限值,路由就被抑制

        一條抑制的路由,當懲罰值小於限值(Suppress 2000)時,重新被傳遞

        當懲罰值低於一半的重新加載值(Reuse 750)得時候將會被清除

        一條被抑制的時候不會超過最大懲罰值

        一條不可達的路由將會已H的狀態顯示在BGP表中

        針對某個鄰居過來的路徑生效而不是這條路徑本身

        只對EBGP路由有效

        半衰期Half-time(15分鍾);最大半衰期 Max-suppress-time (4Xhalf-time 60min  );Per-flap penalty 無法配置 1000

Router(config)#router bgp 66
Router(config-router)#bgp dampening 15 750 2000 60
Router#show ip bgp dampening flap-statistics         查看閃動的狀態
Router#show ip bgp dampening dampened-paths 查看正在衰減的路由
Router#show ip bgp dampening parameters

*d 設置為damp
*h 設置為history
*s 可以放進路由表,不能傳遞給鄰居
*r 不會放進路由表,可以傳遞給鄰居

     五、BGP綜合實驗

      1、基本配置

        AS12345中R4/R5都是RR,要求用動態建立BGP鄰居的方式建立IBGP,並且要求建立盡可能長的TCP連接。

        R1屬於10001,與R2建立一條EBGP鄰居關系。要求用兩台路由器的loo0建立;要求此TCP建立的session無論什么情況,都只能由R1發起,也就是說是通過R1的隨機端口到R2的179端口,R2不能主動發起於R1的TCP連接請求;使用最小的EBGP多跳;不能用ACL和任何過濾。

        R1與R3建立一條EBGPsession,要求用最少的配置

        R10與R8建立一條EBGP鄰居。要求R10不能出現EBGP關鍵字,R8不能出現UPDATE關鍵字;R8不能與R10的fa0/0建立EBGP鄰居;當BGP建立時,無論如何都是從R10發起到R8 179端口,用ACL來完成。

        R10和R9建立正常的EBGP鄰居關系

 

R4配置:

R4(config)#router bgp 12345                                    啟bgp12345
R4(config-router)#bgp listen range 0.0.0.0/0 peer-group IBGP 動態建立bgp鄰居
R4(config-router)#neighbor IBGP peer-group 啟一個盒子IBGP
R4(config-router)#neighbor IBGP remote-as 12345 把命令裝進IBGP盒子里面
R4(config-router)#neighbor IBGP update-source loopback 0 把命令裝進IBGP盒子里面

R5配置:

R5(config)#router bgp 12345
R5(config-router)#neighbor IBGP peer-group
R5(config-router)#neighbor IBGP remote-as 12345
R5(config-router)#neighbor IBGP update-source loopback 0
R5(config-router)#bgp listen range 0.0.0.0/0 peer-group IBGP

R2:、R3、R6、R7、R8、R9配置:

 router bgp 12345
 neighbor 4.4.4.4 remote-as 12345
 neighbor 4.4.4.4 update-source Loopback0
 neighbor 5.5.5.5 remote-as 12345
 neighbor 5.5.5.5 update-source Loopback0

 R1配置:

R1(config)#ip route 2.2.2.2 255.255.255.255 12.1.1.2     明細路由
R2(config)#ip route 0.0.0.0 0.0.0.0 12.1.1.1        R2到R1環回口路由用默認路由,默認路由不會主動發起連接,被動響應
R1#show tcp brief 查看誰發起的session連接

R3配置:

R3(config)# router bgp 12345
R3(config-router)#neighbor 13.1.1.1 remote-as 10001 物理口建立BGP,配置最少

R1(config)#router bgp 10001
R1(config-router)#neighbor 13.1.1.3 remote-as 12345

 R8配置:R8用物理口與R10的環回口建立鄰居

R8(config)#ip route 10.10.10.10 255.255.255.0 100.1.1.10
R8(config)#router bgp 12345
R8(config-router)#neighbor 10.10.10.10 remote-as 34567
R8(config-router)#neighbor 10.10.10.10 ebgp-multihop

R10配置:

R10(config)#router bgp 34567
R10(config-router)#neighbor 100.1.1.8 remote-as 12345
R10(config-router)#neighbor 100.1.1.8 update-source loopback 0
R10(config)#ip access-list extended tcp
R10(config-ext-nacl)#deny tcp host 100.1.1.8 host 10.10.10.10 eq 179
R10(config-ext-nacl)#permit ip any any
R10(config-if)#ip access-group tcp in
R8#clear ip bgp 10.10.10.10

 R9配置:

R9(config-router)#neighbor 100.1.2.10 remote-as 34567

R10(config-if)#router bgp 34567
R10(config-router)#neighbor 100.1.2.9 remote-as 12345

 高級配置

    1、在R5上,通過network宣告一條5.0.0.0/8的路由到BGP中,R1收不到這條路由,此解決方法只能在R5的BGP上做,不可以在任何地方增加接口或者靜態或者OSPF匯總BGP手動匯總(auto-summ/comm)

    2、在R5上向BGP下發默認路由。(network 0.0.0.0)

    3、在R1上增加一條環回口loo104,地址為:104.1.1.1 255.255.255.0

      104.1.2.1 255.255.255.0 se

      104.1.3.1 255.255.255.0 se

      104.1.4.1 255.255.255.0 se

      104.1.5.1 255.255.255.0 se

    用最小的命令行把這些路由放進BGP,並且使R5看到這些路由的ORIGINE TYPE是IGP

    4、在R8 R9上做配置,使得R10接受UPDATE時,這幾條的AS-PATH為12345 34567 10001 使用最少的配置步驟和命令行。

    5、在R10上做配置,確保R10能收到這4條路由(allowas-in 1)

    6、R10上除了104.1.2.1其余的都從R3到達R1,且負載

 R5配置:

R5(config)#router bgp 12345
R5(config-router)#auto-summary
R5(config-router)#network 5.0.0.0
R5(config)#access-list 1 permit 5.0.0.0 抓取路由
R5(config)#route-map NO-E
R5(config-route-map)#match ip address 1
R5(config-route-map)#set community no-export 打上不要傳出本AS區標簽
R5(config)#route-map NO-E permit 999 大號放行
R5(config)#router bgp 12345
R5(config-router)#neighbor IBGP route-map NO-E out
R5(config-router)#neighbor IBGP send-community

 R5配置:

R5(config-router)#neighbor IBGP default-originate  向所有鄰居下發默認路由

R1配置:

R1(config)#int loopback 104
R1(config-if)#ip address 104.1.1.1 255.255.255.0
R1(config-if)#ip address 104.1.2.1 255.255.255.0 secondary 
R1(config-if)#ip address 104.1.3.1 255.255.255.0 secondary 
R1(config-if)#ip address 104.1.4.1 255.255.255.0 secondary 
R1(config-if)#ip address 104.1.5.1 255.255.255.0 secondary
R1(config)#route-map C
R1(config-route-map)#match interface loopback 104
R1(config-route-map)#set origin igp
R1(config-route-map)#router bgp 10001
R1(config-router)#redistribute connected route-map C      重分布

 R4配置:

R4(config)#router bgp 12345
R4(config-router)#neighbor IBGP route-reflector-client 

R5(config)#router bgp 12345
R5(config-router)#neighbor IBGP route-reflector-client

R8配置:

R8(config)#access-list 21 permit 104.1.0.0 0.0.7.255
R8(config)#route-map AS
R8(config-route-map)#match ip address 21
R8(config-route-map)#set as-path prepend 34567
R8(config)#route-map AS permit 999
R8(config-route-map)#router bgp 12345
R8(config-router)#neighbor 10.10.10.10 route-map AS out

R9配置:

R9(config)#access-list 21 permit 104.1.0.0 0.0.7.255
R9(config)#route-map AS
R9(config-route-map)#match ip address 21
R9(config-route-map)#set as-path prepend 34567
R9(config)#route-map AS permit 999
R9(config-route-map)#router bgp 12345
R9(config-router)#neighbor 100.1.2.10 route-map AS out

R10配置:解決第5條

R10(config)#router bgp 34567
R10(config-router)#neighbor 100.1.1.8 allowas-in 1
R10(config-router)#neighbor 100.1.2.9 allowas-in 1

 R2、R3、R6、R7、R8,R9配置:解答第6條

R2(config)#ip prefix-list abc permit 104.1.1.0/24
R2(config)#ip prefix-list abc permit 104.1.3.0/24
R2(config)#ip prefix-list abc permit 104.1.4.0/24
R2(config)#ip prefix-list abc permit 104.1.5.0/24
R2(config)#route-map L
R2(config-route-map)#match ip address prefix-list abc
R2(config-route-map)#set local-preference 99
R2(config)#route-map L permit 999
R2(config-route-map)#router bgp 12345
R2(config-router)#neighbor 4.4.4.4 route-map L out

 未完待續

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM