示例:配置 BGP 路由抖动阻尼参数
此示例说明如何配置阻尼参数。
要求
开始之前,请配置路由器接口并配置路由协议。
概述
此示例有三个路由设备。设备 R2 与设备 R1 和设备 R3 具有外部 BGP (EBGP) 连接。
设备 R1 和设备 R3 配置了一些用于测试目的的静态路由,这些静态路由通过 BGP 播发到设备 R2。
设备 R2 根据以下条件抑制从设备 R1 和设备 R3 接收的路由:
屏蔽长度等于或大于 17 的所有前缀比掩码长度介于 9 和 16 之间的路由更积极地阻尼。
掩码长度介于 0 和 8(含)之间的潮湿路由,小于掩码长度大于 8 的路由。
完全不要弄湿 10.128.0.0/9 前缀。
将路由从路由表导出到转发表时,将评估路由策略。仅从路由表中导出活动路由。
图 1 显示了示例网络。
#configuration649__bgp-damp-policy-st本节介绍设备 R2 上的步骤。
配置
程序
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到层次结构级别的 CLI [edit]
中。
设备 R1
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.1/30 set interfaces lo0 unit 0 family inet address 192.168.0.1/32 set protocols bgp group ext type external set protocols bgp group ext export send-direct-and-static set protocols bgp group ext peer-as 200 set protocols bgp group ext neighbor 10.0.0.2 set policy-options policy-statement send-direct-and-static term 1 from protocol direct set policy-options policy-statement send-direct-and-static term 1 from protocol static set policy-options policy-statement send-direct-and-static term 1 then accept set routing-options static route 172.16.0.0/16 reject set routing-options static route 172.16.128.0/17 reject set routing-options static route 172.16.192.0/20 reject set routing-options static route 10.0.0.0/9 reject set routing-options static route 172.16.233.0/7 reject set routing-options static route 10.224.0.0/11 reject set routing-options static route 0.0.0.0/0 reject set routing-options autonomous-system 100
设备 R2
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.2/30 set interfaces fe-1/2/1 unit 0 family inet address 10.1.0.1/30 set interfaces lo0 unit 0 family inet address 192.168.0.2/32 set protocols bgp damping set protocols bgp group ext type external set protocols bgp group ext import damp set protocols bgp group ext export send-direct set protocols bgp group ext neighbor 10.0.0.1 peer-as 100 set protocols bgp group ext neighbor 10.1.0.2 peer-as 300 set policy-options policy-statement damp term 1 from route-filter 10.128.0.0/9 exact damping dry set policy-options policy-statement damp term 1 from route-filter 0.0.0.0/0 prefix-length-range /0-/8 damping timid set policy-options policy-statement damp term 1 from route-filter 0.0.0.0/0 prefix-length-range /17-/32 damping aggressive set policy-options policy-statement send-direct term 1 from protocol direct set policy-options policy-statement send-direct term 1 then accept set policy-options damping aggressive half-life 30 set policy-options damping aggressive suppress 2500 set policy-options damping timid half-life 5 set policy-options damping dry disable set routing-options autonomous-system 200
设备 R3
set interfaces fe-1/2/1 unit 0 family inet address 10.1.0.2/30 set interfaces lo0 unit 0 family inet address 192.168.0.3/32 set protocols bgp group ext type external set protocols bgp group ext export send-direct-and-static set protocols bgp group ext peer-as 200 set protocols bgp group ext neighbor 10.1.0.1 set policy-options policy-statement send-direct-and-static term 1 from protocol direct set policy-options policy-statement send-direct-and-static term 1 from protocol static set policy-options policy-statement send-direct-and-static term 1 then accept set routing-options static route 10.128.0.0/9 reject set routing-options autonomous-system 300
分步过程
下面的示例要求您在各个配置层级中进行导航。有关导航 CLI 的信息,请参阅《Junos OS CLI 用户指南》中的在配置模式下使用 CLI 编辑器。
要配置阻尼参数:
配置接口。
[edit interfaces] user@R2# set fe-1/2/0 unit 0 family inet address 10.0.0.2/30 user@R2# set fe-1/2/1 unit 0 family inet address 10.1.0.1/30 user@R2# set lo0 unit 0 family inet address 192.168.0.2/32
配置 BGP 邻接方。
[edit protocols bgp group ext] user@R2# set type external user@R2# set neighbor 10.0.0.1 peer-as 100 user@R2# set neighbor 10.1.0.2 peer-as 300
创建和配置阻尼参数组。
[edit policy-options] user@R2# set damping aggressive half-life 30 user@R2# set damping aggressive suppress 2500 user@R2# set damping timid half-life 5 user@R2# set damping dry disable
配置阻尼策略。
[edit policy-options policy-statement damp term 1] user@R2# set from route-filter 10.128.0.0/9 exact damping dry user@R2# set from route-filter 0.0.0.0/0 prefix-length-range /0-/8 damping timid user@R2# set from route-filter 0.0.0.0/0 prefix-length-range /17-/32 damping aggressive
为 BGP 启用阻尼。
[edit protocols bgp] user@R2# set damping
应用该策略作为 BGP 邻接方的导入策略。
[edit protocols bgp group ext] user@R2# set import damp
注:您可以在相同或不同的
import
语句中一次或多次引用同一路由策略。配置导出策略。
[edit policy-options policy-statement send-direct term 1] user@R2# set from protocol direct user@R2# set then accept
应用导出策略。
[edit protocols bgp group ext] user@R2# set export send-direct
配置自治系统 (AS) 编号。
[edit routing-options] user@R2# set autonomous-system 200
结果
在配置模式下,通过发出 show interfaces
、 show protocols
、 show policy-options
和 show routing-options
命令来确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
user@R2# show interfaces fe-1/2/0 { unit 0 { family inet { address 10.0.0.2/30; } } } fe-1/2/1 { unit 0 { family inet { address 10.1.0.1/30; } } } lo0 { unit 0 { family inet { address 192.168.0.2/32; } } }
user@R2# show protocols bgp { damping; group ext { type external; import damp; export send-direct; neighbor 10.0.0.1 { peer-as 100; } neighbor 10.1.0.2 { peer-as 300; } } }
user@R2# show policy-options policy-statement damp { term 1 { from { route-filter 10.128.0.0/9 exact damping dry; route-filter 0.0.0.0/0 prefix-length-range /0-/8 damping timid; route-filter 0.0.0.0/0 prefix-length-range /17-/32 damping aggressive; } } } policy-statement send-direct { term 1 { from protocol direct; then accept; } } damping aggressive { half-life 30; suppress 2500; } damping timid { half-life 5; } damping dry { disable; }
user@R2# show routing-options autonomous-system 200;
如果完成设备配置,请从配置模式输入 commit
。
验证
确认配置工作正常。
导致某些路由发生抖动
目的
要验证路由抖动阻尼策略,某些路由必须抖动。拥有实时互联网馈送几乎可以保证存在一定数量的路由抖动。如果可以控制播发路由的远程系统,则可以修改播发路由器的策略,以启用所有路由或给定前缀的播发和撤销。在测试环境中,您可以通过清除 BGP 邻接方或重新启动 BGP 邻接方上的路由进程来导致路由抖动,如下所示。
操作
在设备 R1 和设备 R3 上的操作模式下,输入 restart routing
命令。
在生产网络中谨慎使用此命令。
user@R1> restart routing R1 started, pid 10474
user@R3> restart routing R3 started, pid 10478
意义
在设备 R2 上,来自邻接方的所有路由都将撤回并重新播发。
检查路由抖动
目的
查看邻居抖动的数量。
操作
在操作模式下,输入 show bgp summary
命令。
user@R2> show bgp summary Groups: 1 Peers: 2 Down peers: 0 Table Tot Paths Act Paths Suppressed History Damp State Pending inet.0 12 1 11 0 11 0 Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped... 10.0.0.1 100 10 10 0 4 2:50 0/9/0/9 0/0/0/0 10.1.0.2 300 10 10 0 4 2:53 1/3/1/2 0/0/0/0
意义
此输出是在设备 R2 的邻居上重新启动路由进程四次后捕获的。
验证路由抖动阻尼
目的
验证路由是否由于阻尼而被隐藏。
操作
在操作模式下,输入 show route damping suppressed
命令。
user@R2> show route damping suppressed inet.0: 15 destinations, 17 routes (6 active, 0 holddown, 11 hidden) + = Active Route, - = Last Active, * = Both 0.0.0.0/0 [BGP ] 00:00:12, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0 10.0.0.0/9 [BGP ] 00:00:12, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0 10.0.0.0/30 [BGP ] 00:00:12, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0 10.1.0.0/30 [BGP ] 00:00:15, localpref 100 AS path: 300 I, validation-state: unverified > to 10.1.0.2 via fe-1/2/1.0 10.224.0.0/11 [BGP ] 00:00:12, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0 172.16.0.0/16 [BGP ] 00:00:12, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0 172.16.128.0/17 [BGP ] 00:00:12, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0 172.16.192.0/20 [BGP ] 00:00:12, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0 192.168.0.1/32 [BGP ] 00:00:12, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0 192.168.0.3/32 [BGP ] 00:00:15, localpref 100 AS path: 300 I, validation-state: unverified > to 10.1.0.2 via fe-1/2/1.0 172.16.233.0/7 [BGP ] 00:00:12, localpref 100 AS path: 100 I, validation-state: unverified > to 10.0.0.1 via fe-1/2/0.0
意义
输出显示一些路由不稳定。由于阻尼,有11条路线被隐藏。
显示阻尼路线的详细信息
目的
显示阻尼路径的详细信息。
操作
在操作模式下,输入 show route damping suppressed 172.16.192.0/20 detail
命令。
user@R2> show route damping suppressed 172.16.192.0/20 detail inet.0: 15 destinations, 17 routes (6 active, 0 holddown, 11 hidden) 172.16.192.0/20 (1 entry, 0 announced) BGP /-101 Next hop type: Router, Next hop index: 758 Address: 0x9414484 Next-hop reference count: 9 Source: 10.0.0.1 Next hop: 10.0.0.1 via fe-1/2/0.0, selected Session Id: 0x100201 State: <Hidden Ext> Local AS: 200 Peer AS: 100 Age: 52 Validation State: unverified Task: BGP_100.10.0.0.1+55922 AS path: 100 I Localpref: 100 Router ID: 192.168.0.1 Merit (last update/now): 4278/4196 damping-parameters: aggressive Last update: 00:00:52 First update: 01:01:55 Flaps: 8 Suppressed. Reusable in: 01:14:40 Preference will be: 170
意义
此输出指示显示的路由的掩码长度等于或大于 /17,并确认它已正确映射到主动阻尼配置文件。您还可以查看路由的当前(和最后一个)品质因数值,以及路由在保持稳定时预计何时变为活动状态。
验证默认阻尼参数是否有效
目的
使用 /16 掩码定位阻尼路由可确认默认参数有效。
操作
在操作模式下,输入 show route damping suppressed detail | match 0/16
命令。
user@R2> show route damping suppressed detail | match 0/16 172.16.0.0/16 (1 entry, 0 announced)
user@R2> show route damping suppressed 172.16.0.0/16 detail inet.0: 15 destinations, 17 routes (6 active, 0 holddown, 11 hidden) 172.16.0.0/16 (1 entry, 0 announced) BGP /-101 Next hop type: Router, Next hop index: 758 Address: 0x9414484 Next-hop reference count: 9 Source: 10.0.0.1 Next hop: 10.0.0.1 via fe-1/2/0.0, selected Session Id: 0x100201 State: <Hidden Ext> Local AS: 200 Peer AS: 100 Age: 1:58 Validation State: unverified Task: BGP_100.10.0.0.1+55922 AS path: 100 I Localpref: 100 Router ID: 192.168.0.1 Merit (last update/now): 3486/3202 Default damping parameters used Last update: 00:01:58 First update: 01:03:01 Flaps: 8 Suppressed. Reusable in: 00:31:40 Preference will be: 170
意义
带有 /16 掩码的路由不受自定义阻尼规则的影响。因此,默认阻尼规则有效。
重复一遍,自定义规则如下所示:
屏蔽长度等于或大于 17 的所有前缀比掩码长度介于 9 和 16 之间的路由更积极地阻尼。
掩码长度介于 0 和 8(含)之间的潮湿路由,小于掩码长度大于 8 的路由。
完全不要弄湿 10.128.0.0/9 前缀。
过滤阻尼信息
目的
使用 OR 分组或级联管道来简化确定用于具有给定掩码长度的线路的阻尼轮廓。
操作
在操作模式下,输入 show route damping suppressed
命令。
user@R2> show route damping suppressed detail | match "0 announced | damp" 0.0.0.0/0 (1 entry, 0 announced) damping-parameters: timid 10.0.0.0/9 (1 entry, 0 announced) Default damping parameters used damping-parameters: aggressive damping-parameters: aggressive 10.224.0.0/11 (1 entry, 0 announced) Default damping parameters used 172.16.0.0/16 (1 entry, 0 announced) Default damping parameters used 172.16.128.0/17 (1 entry, 0 announced) damping-parameters: aggressive 172.16.192.0/20 (1 entry, 0 announced) damping-parameters: aggressive 192.168.0.1/32 (1 entry, 0 announced) damping-parameters: aggressive 192.168.0.3/32 (1 entry, 0 announced) damping-parameters: aggressive 172.16.233.0/7 (1 entry, 0 announced) damping-parameters: timid
意义
当您对 EBGP 路由与阻尼配置文件正确关联感到满意时,可以发出 clear bgp damping
操作模式命令以恢复阻尼路由的活动状态,这将使您的连接恢复正常运行。