Topology:
实验目的:通过实验理解BGP的路由惩罚。
Step 1、配置各台路由器的IP地址,并且使用Ping命令确认各路由器的直连口的互通性。
Step 2、R1,R2之间建立EBGP邻居。通告1.1.1.1/32。
Step 3、R2上配置路由惩罚。
router bgp 2
bgp dampening route-map DAM
ip prefix-list A seq 5 permit 1.1.1.1/32
!
route-map DAM permit 10
match ip address prefix-list A
set dampening 15 750 2000 60
!
route-map DAM permit 20
Step 4、观察路由惩罚的相关参数。
<1>在1.1.1.1/32路由的稳定情况下。
R2#sh ip bgp
BGP table version is 6, local router ID is 2.2.2.2
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
*> 1.1.1.1/32 12.1.1.1 0 0 1 i
R2#sh ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 10
Paths: (1 available, best #1, table Default-IP-Routing-Table)
Not advertised to any peer
1
12.1.1.1 from 12.1.1.1 (1.1.1.1)
Origin IGP, metric 0, localpref 100, valid, external, best
Dampinfo: penalty 575, flapped 3 times in 00:42:36
<2>当R1上的1.1.1.1/32不稳定的情况下。
R2#sh ip bgp dampening parameters
dampening 15 750 2000 60 (route-map DAM 10)
Half-life time : 15 mins Decay Time : 2320 secs
Max suppress penalty: 12000 Max suppress time: 60 mins
Suppress penalty : 2000 Reuse penalty : 750
R2#sh ip bgp dampening flap-statistics
BGP table version is 9, local router ID is 2.2.2.2
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 Flaps Duration Reuse Path
*d 1.1.1.1/32 12.1.1.1 3 00:12:11 00:02:49 1
R2#sh ip bgp dampening dampened-paths
BGP table version is 9, local router ID is 2.2.2.2
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 1.1.1.1/32 12.1.1.1 00:03:19 1 i
R2#sh ip bgp
BGP table version is 9, local router ID is 2.2.2.2
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 1.1.1.1/32 12.1.1.1 0 0 1 i
R2#sh ip route
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback0
12.0.0.0/24 is subnetted, 1 subnets
C 12.1.1.0 is directly connected, Serial0/0
R2#sh ip bgp 1.1.1.1
BGP routing table entry for 1.1.1.1/32, version 9
Paths: (1 available, no best path)
Not advertised to any peer
1, (suppressed due to dampening)
12.1.1.1 from 12.1.1.1 (1.1.1.1)
Origin IGP, metric 0, localpref 100, valid, external
Dampinfo: penalty 2459, flapped 3 times in 00:11:14, reuse in 00:03:49
====================================================
路由惩罚(route dampening)由RFC2439描述,它主要由以下三个目的:
-提供了一种机制,以减少由于不稳定路由引起的路由器处理负载
-防止持续的路由抖动
-增强了路由的稳定性,但不牺牲表现良好的(well-behaved)路由的收敛时间。
half-time 是指半衰期,单位min,每经过half-time的时间,抑制值就会减半,cisco默认15min。
reuse 是指重新使用界限,当一条被抑制路由的惩罚值低于该值后,该路由重新被标记为可用。cisco默认750
suppress 该值就是抑制阀值,超过该值路由被抑制。cisco默认2000
max-suppress 最大抑制时间,被抑制路由的抑制时间超过该值后,不管惩罚值为多少,都会重新标记为可用,cisco默认60min(4倍的half-time)。
bgp dampening 只对EBGP学习过来的路由起作用.对IBGP不起作用.
bgp dampening 使用来抑制一些频繁震荡路由的,它虽然不能阻止一个路由器接收不稳定的路由,但是它能够阻止公布不稳定的路由。
half-life:default 15min
reuse:default 750
suppress: default 2000
max-suppress-time: default 4*half-life=60 mins
penalty:1000
当一条路由出现flap的时候,这条路由会被加上一个1000的penalty,这个penalty会b每5秒钟递减,等到15分钟的时候,penalty会减少到一半就是500。如果这条路由连续出现flap,每一次flap这条路由的penalty都会加1000,比如说出现了3次flap。那么这时候penalty就是接近3000。当pentaly大于2000时候,这条路由就会在bgp table中被标为suppressed。经过了15分钟后(没有发生flap),这条路由的penalty会被减少一半到1500,这条路由还是被标为suppressed。再经过15分钟后,penalty减成750,这条路由才可以重新被active。也就是说经过30分钟,路由器认为这条路由是稳定的,才会把它重新使用它。
如果这条路由不停的flap,好比说20次。这时候penalty会接近20000。每过15分钟Penalty会减少一半,可是到了60分钟的时候,penalty还是大于750,这时候因为已经超过了max-suppress-time,所以这条路由会被重新active。
因为使用damping的弊大于利,所以damping是不推荐使用的。如果一定要用使用默认数值就可以了。
R1+++++++++++++++++++++++++++++++++++++++++++++++++
int lo 0
ip add 1.1.1.1 255.255.255.255
int e0/0
no sh
ip add 12.1.1.1 255.255.255.0
router bgp 1
nei 12.1.1.2 remote 2
net 1.1.1.1 mask 255.255.255.255
R2+++++++++++++++++++++++++++++++++++++++++++
int lo 0
ip add 2.2.2.2 255.255.255.255
int e0/0
no sh
ip add 12.1.1.2 255.255.255.0
router bgp 2
nei 12.1.1.1 remote 1
bgp dampening route-map DAM
ip prefix-list A seq 5 permit 1.1.1.1/32
!
route-map DAM permit 10
match ip address prefix-list A
set dampening 15 750 2000 60
!
route-map DAM permit 20