BGP-20190321-dampening

BGP dampening(懲罰)
BGP這個唯一的EGP協議、這個工作在AS by AS之間的外部網關路由協議、
具有了先天的穩定性、主要體現在以下方面:
(1)採用TCP傳輸層協議、端口號179
(2)協議具有懲罰機制、對不穩定的路由進行懲罰、
下文將介紹懲罰的相關實驗、證明BGP的穩定性、
BGP-20190321-dampening

(1)底層配置
上圖中所有路由器都配有 Loopback 地址,地址分別爲:
R1 Loopback 0 1.1.1.1/32
R2 Loopback 0 2.2.2.2/32

所有路由器之間運行 OSPF,並將 Loopback 0 的地址發佈到 OSPF 中,保證全網Loopback 0 之間是可以通信的。
(2)R1 與 R2 建立 eBGP 鄰居關係。
R1:

R1(config)#router bgp 1
R1(config-router)#bgp router-id 1.1.1.1
R1(config-router)#neighbor 2.2.2.2 remote-as 2
R1(config-router)#neighbor 2.2.2.2 update-source loopback 1
R1(config-router)#neighbor 2.2.2.2 ebgp-multihop 

R2:

R2(config)#router bgp 2 
R2(config-router)#bgp router-id 2.2.2.2
R2(config-router)#neighbor 1.1.1.1 remote-as 1
R2(config-router)#neighbor 1.1.1.1 update-source loopback 0 
R2(config-router)#neighbor 1.1.1.1 ebgp-multihop 
R2(config-router)#network 10.1.1.0 mask 255.255.255.0
R2(config-router)#network 20.1.1.0 mask 255.255.255.0

說明:R2 將 10.1.1.0/24 和 20.1.1.0/24 導入 BGP 路由表中。

確保R1能收到R2發送出來的路由、
R1#sh ip bgp
BGP table version is 3, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

Network Next Hop Metric LocPrf Weight Path
> 10.1.1.0/24 2.2.2.2 0 0 2 i
> 20.1.1.0/24 2.2.2.2 0 0 2 i
R1#

(3)配置BGP懲罰
.針對所有路由配置 BGP Dampening

1、在 R1 上對所有路由配置 BGP Dampening

R1(config)#router bgp 1 
R1(config-router)#bgp dampening

2、查看 BGP Dampening 參數

R1#show ip bgp dampening parameters 
 dampening 15 750 2000 60 (DEFAULT)
  Half-life time      : 15 mins       Decay Time       : 2320 secs
  Max suppress penalty: 12000         Max suppress time: 60 mins
  Suppress penalty    :  2000         Reuse penalty    : 750
R1#

說明:以上值爲 BGP Dampening 默認值。
3、查看被 BGP Dampening 監控的路由

R1#show ip bgp dampening dampened-paths `

R1#

說明:因爲沒有路由發生翻動,所以路由爲空。

4、測試dampening

R2(config)#interface loopback 10
R2(config-if)#shutdown

說明:將 10.1.1.0/24 的接口斷開,表示翻動一次。

R1#show ip bgp 10.1.1.0
BGP routing table entry for 10.1.1.0/24, version 4
Paths: (1 available, no best path)
Flag: 0x820
  Not advertised to any peer
  2 (history entry)
    2.2.2.2 (metric 11) from 2.2.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, external
      Dampinfo: penalty 950, flapped 1 times in 00:01:07
R1#

說明:可以看到,由於10.1.1.0/24 發生了一次翻動,所以有了 penalty 值,爲950。
5、測試dampening
再次shutdown接口、10.1.1.0/24 翻動了多次,現在 penalty 值爲1849 ,但還是低於抑制值 2000。

R2(config)#interface loopback 10
R2(config-if)#sh
R2(config-if)#shutdown 
R2(config-if)#
*Mar  1 00:28:08.647: %LINK-5-CHANGED: Interface Loopback10, changed state to administratively down
*Mar  1 00:28:09.647: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback10, changed state to down
R2(config-if)#no sh
R2(config-if)#no shutdown 
R2(config-if)#sh
R2(config-if)#         
*Mar  1 00:31:10.799: %LINK-3-UPDOWN: Interface Loopback10, changed state to up
*Mar  1 00:31:11.799: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback10, changed state to up
R2(config-if)#shu
R2(config-if)#shutdown 
R2(config-if)#
*Mar  1 00:31:23.143: %LINK-5-CHANGED: Interface Loopback10, changed state to administratively down
*Mar  1 00:31:24.143: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback10, changed state to down
R2(config-if)#shu
R2(config-if)#shutdown 
R2(config-if)#
R1#show ip bgp 10.1.1.0
BGP routing table entry for 10.1.1.0/24, version 6
Paths: (1 available, no best path)
  Not advertised to any peer
  2 (history entry)
    2.2.2.2 (metric 11) from 2.2.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, external
      Dampinfo: penalty 1849, flapped 2 times in 00:03:39
R1#

6、超過數值懲罰路由
說明:翻動 N次後,penalty 值爲 2630,大於抑制值 2000,可以被抑制了。

R1#show ip bgp 10.1.1.0
BGP routing table entry for 10.1.1.0/24, version 8
Paths: (1 available, no best path)
Flag: 0x820
  Not advertised to any peer
  2 (history entry)
    2.2.2.2 (metric 11) from 2.2.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, external
      Dampinfo: penalty 2630, flapped 3 times in 00:06:27
R1#

說明:BGP 路由表中也顯示了 10.1.1.0/24 是被抑制的。

R1#show ip bgp 
BGP table version is 8, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*d 10.1.1.0/24      2.2.2.2                  0             0 2 i
*> 20.1.1.0/24      2.2.2.2                  0             0 2 i
注:*d 10.1.1.0/24 中的d代表是懲罰、
R1#show ip bgp dampening dampened-paths 
BGP table version is 8, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          From             Reuse    Path
*d 10.1.1.0/24      2.2.2.2          00:02:59 2 i

說明:可以看到 10.1.1.0/24 是被抑制的路由,需要注意,只有該路由重新活動 後,才能看見被抑制,否則斷開的路由也是不會顯示在抑制表中的。

(4).針對特定路由配置

R1(config)#access-list 20 permit 20.1.1.0
R1(config)#route-map damo permit 10
R1(config-route-map)#match ip address 20
R1(config-route-map)#set dampening 15 800 2100 60
R1(config-route-map)#exit
R1(config)#route-map damo permit 20   

R1(config)#router bgp 1 
R1(config-router)#bgp dampening route-map damo

說明:只對 20.1.1.0/24 配置 BGP Dampening,並且自定義 Dampening 值。

查看 BGP Dampening 參數

R1#show  ip bgp dampening parameters 
 dampening 15 800 2100 60 (route-map damo 10)
  Half-life time      : 15 mins       Decay Time       : 2345 secs
  Max suppress penalty: 12800         Max suppress time: 60 mins
  Suppress penalty    :  2100         Reuse penalty    : 800

R1#

說明:以上值爲自定義的值。

1、翻滾一次

R2(config)#interface loopback 20
R2(config-if)#shutdown 
R2(config-if)#no shutdown 

R1#sh ip bgp 20.1.1.0
BGP routing table entry for 20.1.1.0/24, version 10
Paths: (1 available, no best path)
Flag: 0x820
  Not advertised to any peer
  2 (history entry)
    2.2.2.2 (metric 11) from 2.2.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, external
      Dampinfo: penalty 1000, flapped 1 times in 00:00:18
R1#

說明:由於 20.1.1.0/24 翻動了一次,當前 penalty 值爲 1000。

2、翻滾三次

R1#sh ip bgp 20.1.1.0
BGP routing table entry for 20.1.1.0/24, version 14
Paths: (1 available, no best path)
Flag: 0x820
  Not advertised to any peer
  2 (history entry)
    2.2.2.2 (metric 11) from 2.2.2.2 (2.2.2.2)
      Origin IGP, metric 0, localpref 100, external
      Dampinfo: penalty 2807, flapped 3 times in 00:03:58

R1#sh ip bgp dampening dampened-paths 
BGP table version is 14, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          From             Reuse    Path
*d 20.1.1.0/24      2.2.2.2          00:04:49 2 i

說明:BGP 路由表中也顯示 20.1.1.0/24 是被抑制的。

R1#sh ip bgp                          
BGP table version is 14, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
              r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete

   Network          Next Hop            Metric LocPrf Weight Path
*> 10.1.1.0/24      2.2.2.2                  0             0 2 i
*d 20.1.1.0/24      2.2.2.2                  0             0 2 i
R1#
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章