- play_arrow 配置防火墙过滤器
- play_arrow 了解防火墙过滤器如何保护您的网络
- play_arrow 防火墙过滤器匹配条件和操作
- 防火墙过滤器概述(OCX 系列)
- ACX 系列路由器上的防火墙过滤器配置文件概述(Junos OS 演化版)
- 了解防火墙过滤器匹配条件
- 了解防火墙过滤器规划
- 了解如何评估防火墙过滤器
- 了解防火墙过滤器匹配条件
- 防火墙过滤器灵活匹配条件
- 防火墙过滤器非终止操作
- 防火墙过滤器终止操作
- 防火墙过滤器匹配条件和操作(ACX 系列路由器)
- ACX 系列路由器中的防火墙过滤器匹配条件和操作 (Junos OS 演化版)
- 与协议无关的流量的防火墙过滤器匹配条件
- IPv4 流量的防火墙过滤器匹配条件
- IPv6 流量的防火墙过滤器匹配条件
- 基于数字或文本别名的防火墙过滤器匹配条件
- 基于位字段值的防火墙过滤器匹配条件
- 基于地址字段的防火墙过滤器匹配条件
- 基于地址类的防火墙过滤器匹配条件
- 了解 MPLS 流量的基于 IP 的过滤和选择性端口镜像
- MPLS 流量的防火墙过滤器匹配条件
- MPLS 标记的 IPv4 或 IPv6 流量的防火墙过滤器匹配条件
- VPLS 流量的防火墙过滤器匹配条件
- 第 2 层 CCC 流量的防火墙过滤器匹配条件
- 第 2 层桥接流量的防火墙过滤器匹配条件
- 环路接口上的防火墙过滤器支持
- play_arrow 将防火墙过滤器应用于路由引擎流量
- 在第 3 层 VPN 中的路由实例的环路接口上配置逻辑单元
- 示例:配置过滤器以根据前缀列表限制对端口的 TCP 访问
- 示例:配置无状态防火墙过滤器以接受来自可信源的流量
- 示例:配置过滤器以阻止 Telnet 和 SSH 访问
- 示例:配置过滤器以阻止 TFTP 访问
- 示例:配置过滤器以接受基于 IPv6 TCP 标志的数据包
- 示例:配置过滤器以阻止对端口的 TCP 访问(来自指定 BGP 对等方除外)
- 示例:配置无状态防火墙过滤器以防止 TCP 和 ICMP 泛滥
- 示例:使用每秒数据包数速率限制过滤器保护路由引擎
- 示例:配置过滤器以排除 LAC 订阅者的 DHCPv6 和 ICMPv6 控制流量
- DHCP 防火墙过滤器的端口号要求
- 示例:配置 DHCP 防火墙过滤器以保护路由引擎
- play_arrow 将防火墙过滤器应用于传输流量
- 示例:配置过滤器以用作入口队列过滤器
- 示例:配置过滤器以匹配 IPv6 标志
- 示例:配置过滤器以匹配端口和协议字段
- 示例:配置过滤器以计算接受和拒绝的数据包
- 示例:配置过滤器以计数和丢弃 IP 选项数据包
- 示例:配置过滤器以对 IP 选项数据包进行计数
- 示例:配置过滤器以对接受的数据包进行计数和采样
- 示例:配置过滤器以将 DSCP 位设置为零
- 示例:配置过滤器以将 DSCP 位设置为零
- 示例:将筛选器配置为匹配两个不相关的条件
- 示例:将过滤器配置为基于地址接受 DHCP 数据包
- 示例:配置过滤器以接受来自前缀的 OSPF 数据包
- 示例:配置无状态防火墙过滤器以处理片段
- 配置防火墙过滤器以防止或允许 IPv4 数据包分段
- 配置防火墙过滤器以丢弃带有移动扩展标头的入口 IPv6 数据包
- 示例:基于 IPv6 源或目标 IP 地址配置出口过滤器
- 示例:基于目标类配置速率限制过滤器
- play_arrow 在逻辑系统中配置防火墙过滤器
- play_arrow 配置防火墙过滤器记帐和日志记录
- play_arrow 将多个防火墙过滤器连接到单个接口
- play_arrow 将单个防火墙过滤器连接到多个接口
- play_arrow 配置跨 IP 网络的基于过滤器的隧道
- play_arrow 配置服务过滤器
- play_arrow 配置简单筛选器
- play_arrow 配置第 2 层防火墙过滤器
- play_arrow 为转发、分段和监管配置防火墙过滤器
- play_arrow 配置防火墙过滤器(EX 系列交换机)
- EX 系列交换机的防火墙过滤器概述
- 了解防火墙过滤器的规划
- 了解防火墙过滤器匹配条件
- 了解防火墙过滤器如何控制数据包流
- 了解如何评估防火墙过滤器
- 了解 EX 系列交换机上桥接数据包和路由数据包的防火墙过滤器处理点
- EX 系列交换机的防火墙过滤器匹配条件、操作和操作修改符
- EX 系列交换机上防火墙过滤器匹配条件、操作和操作修饰符的平台支持
- 支持交换机上环路防火墙过滤器的匹配条件和操作
- 配置防火墙过滤器(CLI 过程)
- 了解防火墙过滤器如何测试数据包的协议
- 了解 EX 系列交换机基于过滤器的转发
- 示例:为 EX 系列交换机上的端口、VLAN 和路由器流量配置防火墙过滤器
- 示例:在 EX 系列交换机的管理接口上配置防火墙过滤器
- 示例:使用基于过滤器的转发将应用程序流量路由到安全设备
- 示例:将防火墙过滤器应用于启用了 802.1X 或 MAC RADIUS 身份验证的接口上的多个请求方
- 验证监管器是否正常运行
- 防火墙过滤器故障排除
- play_arrow 配置防火墙过滤器(QFX 系列交换机、EX4600 交换机、PTX 系列路由器)
- 防火墙过滤器概述(QFX 系列)
- 了解防火墙过滤器规划
- 规划要创建的防火墙过滤器数量
- 防火墙过滤器匹配条件和操作(QFX 和 EX 系列交换机)
- 防火墙过滤器匹配条件和操作(QFX10000交换机)
- 防火墙过滤器匹配条件和操作(PTX 系列路由器)
- PTX 系列数据包传输路由器和 T 系列矩阵路由器之间的防火墙和监管差异
- 配置防火墙过滤器
- 将防火墙过滤器应用于接口
- 环路接口上的 MPLS 防火墙过滤器概述
- 在交换机上配置 MPLS 防火墙过滤器和监管器
- 在路由器上配置 MPLS 防火墙过滤器和监管器
- 配置 MPLS 防火墙过滤器和监管器
- 了解防火墙过滤器如何测试协议
- 了解桥接和路由数据包的防火墙过滤器处理点
- 了解基于过滤器的转发
- 示例:使用基于过滤器的转发将应用程序流量路由到安全设备
- 配置防火墙过滤器以解封装 GRE 或 IPIP 流量
- 验证防火墙过滤器是否正常运行
- 监控防火墙过滤器流量
- 防火墙过滤器配置疑难解答
- play_arrow 配置防火墙过滤器计费和日志记录(EX9200 交换机)
-
- play_arrow 配置流量监管器
- play_arrow 了解流量监管器
- 监管器实施概述
- ARP 监管器概述
- 示例:配置 ARP 监管器
- 了解监管器和令牌桶算法的优势
- 确定流量监管器的适当突发大小
- 使用流量监管控制网络访问概述
- 流量监管器类型
- 监管器和防火墙过滤器操作的顺序
- 了解监管数据包的帧长度
- 支持的监管标准
- 分层监管器配置概述
- 了解增强型分层监管器
- 基于每秒数据包数 (pps) 的监管器概述
- 应用流量监管器的准则
- 聚合以太网接口的监管器支持概述
- 示例:为物理接口上的聚合流量配置物理接口监管器
- PTX 系列数据包传输路由器和 T 系列矩阵路由器之间的防火墙和监管差异
- ACX 系列路由器上的分层监管器概述
- 在 ACX 系列路由器上配置分层监管器的准则
- ACX 系列路由器上的分层监管器模式
- 处理 ACX 系列路由器上的分层监管器
- 对 ACX 系列路由器上的分层监管器执行的操作
- 在 ACX 系列路由器上配置聚合父监管器和子监管器
- play_arrow 配置监管器速率限制和操作
- play_arrow 配置第 2 层监管器
- play_arrow 在第 3 层配置双色和三色流量监管器
- play_arrow 在第 3 层配置逻辑和物理接口流量监管器
- play_arrow 在交换机上配置监管器
-
- play_arrow 配置语句和操作命令
- play_arrow 故障排除
- play_arrow 知识库
-
示例:配置动态路由策略
此示例说明如何在不受标准配置数据库中所需验证的动态数据库中配置路由策略对象。
概述
提交配置更改所需的验证过程可能需要大量的开销和时间。
将更改提交到动态数据库所需的时间比标准配置数据库短得多。您可以在标准数据库中配置的路由策略中引用这些策略和策略对象。BGP 是唯一可以应用引用动态数据库中配置的策略和策略对象的路由策略的协议。根据动态数据库中配置的对象配置并提交路由策略后,可以通过更改动态数据库配置来快速更新任何现有路由策略。
由于 Junos OS 不会验证对动态数据库的配置更改,因此在使用此功能时,应在提交所有配置更改之前测试并验证这些更改。
图 1 显示了示例网络。

该示例包括三个已建立外部 BGP (EBGP) 会话的路由器。只有设备 R1 使用动态数据库。
在设备 R0 的 fe-1/2/1 接口上,配置了多个 IPv4 接口,路由策略将这些前缀注入 BGP, from interface fe-1/2/1.0
使用策略条件作为指定设备 R0 的 fe-1/2/1 接口上配置的所有 IP 地址的简写方法。
同样,在设备 R2 的 fe-1/2/3 接口上,配置了多个 IPv4 地址,路由策略将这些前缀注入 BGP。设备 R2 的配置与设备 R0 的配置略有不同,因为设备 R2 的配置演示了前缀列表的使用。
在设备 R1 上的动态数据库中,定义了两个前缀列表,一个用于从设备 R0 获知的接口地址,另一个用于从设备 R2 获知的接口地址。设备 R1 的标准数据库包含路由策略,其前缀列表类似于动态数据库中定义的前缀列表。
在与设备 R0 的对等会话中,设备 R1 应用了静态数据库策略。相反,在与设备 R2 的对等会话中,设备 R1 的配置引用动态数据库。
本节 验证 分析了这些不同配置的结果。
#configuration776__policy-dynamic-st本节介绍设备 R1 动态数据库上的步骤。
#configuration776__policy-standard-st本节介绍设备 R1 标准数据库上的步骤。
配置
程序
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改与您的网络配置匹配所需的任何详细信息,然后将命令复制并粘贴到层次结构级别的 CLI [edit]
中。
设备 R0
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.1/30 set interfaces fe-1/2/1 unit 0 family inet address 172.16.4.1/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.3.1/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.2.1/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.1.1/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.5.1/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.6.1/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.7.1/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.8.1/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.9.1/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.10.1/24 set interfaces lo0 unit 0 family inet address 10.255.14.151/32 set protocols bgp group ext type external set protocols bgp group ext neighbor 10.0.0.2 export t2 set protocols bgp group ext neighbor 10.0.0.2 peer-as 200 set policy-options policy-statement t2 from interface fe-1/2/0.0 set policy-options policy-statement t2 from interface fe-1/2/1.0 set policy-options policy-statement t2 then accept set routing-options router-id 10.255.14.151 set routing-options autonomous-system 100
设备 R1 动态数据库
[edit dynamic] set policy-options prefix-list dyn_prfx1 172.16.1.0/24 set policy-options prefix-list dyn_prfx1 172.16.2.0/24 set policy-options prefix-list dyn_prfx1 172.16.3.0/24 set policy-options prefix-list dyn_prfx1 172.16.4.0/24 set policy-options prefix-list dyn_prfx1 172.16.5.0/24 set policy-options prefix-list dyn_prfx1 172.16.6.0/24 set policy-options prefix-list dyn_prfx1 172.16.7.0/24 set policy-options prefix-list dyn_prfx1 172.16.8.0/24 set policy-options prefix-list dyn_prfx2 172.16.2.0/24 set policy-options prefix-list dyn_prfx2 172.16.3.0/24 set policy-options prefix-list dyn_prfx2 172.16.4.0/24 set policy-options prefix-list dyn_prfx2 172.16.5.0/24 set policy-options prefix-list dyn_prfx2 172.16.6.0/24 set policy-options policy-statement dyn_policy1 term t1 from prefix-list dyn_prfx1 set policy-options policy-statement dyn_policy1 term t1 then accept set policy-options policy-statement dyn_policy1 term t2 then reject set policy-options policy-statement dyn_policy2 term t1 from prefix-list dyn_prfx2 set policy-options policy-statement dyn_policy2 term t1 then accept set policy-options policy-statement dyn_policy2 term t2 then reject
设备 R1 标准数据库
set interfaces fe-1/2/0 unit 0 family inet address 10.0.0.2/30 set interfaces fe-1/2/2 unit 0 family inet address 10.1.0.1/30 set interfaces fe-1/2/1 unit 0 family inet address 172.16.4.2/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.3.2/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.2.2/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.1.2/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.5.2/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.6.2/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.7.2/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.8.2/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.9.2/24 set interfaces fe-1/2/1 unit 0 family inet address 172.16.10.2/24 set interfaces fe-1/2/3 unit 0 family inet address 172.16.22.2/24 set interfaces fe-1/2/3 unit 0 family inet address 172.16.23.2/24 set interfaces fe-1/2/3 unit 0 family inet address 172.16.24.2/24 set interfaces fe-1/2/3 unit 0 family inet address 172.16.25.2/24 set interfaces fe-1/2/3 unit 0 family inet address 172.16.26.2/24 set interfaces lo0 unit 0 family inet address 192.168.0.2/32 set protocols bgp group to_r0 idle-after-switch-over 300 set protocols bgp group to_r0 neighbor 10.0.0.1 import dyn_policy1 set protocols bgp group to_r0 neighbor 10.0.0.1 export dyn_policy2 set protocols bgp group to_r0 neighbor 10.0.0.1 peer-as 100 set protocols bgp group to_R2 import static_policy1 set protocols bgp group to_R2 export static_policy2 set protocols bgp group to_R2 idle-after-switch-over 300 set protocols bgp group to_R2 neighbor 10.1.0.2 peer-as 300 set policy-options prefix-list static_prfx1 172.16.22.0/24 set policy-options prefix-list static_prfx1 172.16.23.0/24 set policy-options prefix-list static_prfx1 172.16.24.0/24 set policy-options prefix-list static_prfx1 172.16.25.0/24 set policy-options prefix-list static_prfx2 172.16.1.0/24 set policy-options prefix-list static_prfx2 172.16.2.0/24 set policy-options prefix-list static_prfx2 172.16.3.0/24 set policy-options prefix-list static_prfx2 172.16.4.0/24 set policy-options policy-statement dyn_policy1 dynamic-db set policy-options policy-statement dyn_policy2 dynamic-db set policy-options policy-statement static_policy1 term t1 from prefix-list static_prfx1 set policy-options policy-statement static_policy1 term t1 then accept set policy-options policy-statement static_policy1 term t2 then reject set policy-options policy-statement static_policy2 term t1 from prefix-list static_prfx2 set policy-options policy-statement static_policy2 term t1 then accept set policy-options policy-statement static_policy2 term t2 then reject set routing-options autonomous-system 200
设备 R2
set interfaces fe-1/2/2 unit 0 family inet address 10.1.0.2/30 set interfaces fe-1/2/3 unit 0 family inet address 172.16.22.1/24 set interfaces fe-1/2/3 unit 0 family inet address 172.16.23.1/24 set interfaces fe-1/2/3 unit 0 family inet address 172.16.24.1/24 set interfaces fe-1/2/3 unit 0 family inet address 172.16.25.1/24 set interfaces fe-1/2/3 unit 0 family inet address 172.16.26.1/24 set interfaces lo0 unit 0 family inet address 192.168.0.3/32 set protocols bgp group to_vin neighbor 10.1.0.1 export p1 set protocols bgp group to_vin neighbor 10.1.0.1 peer-as 200 set policy-options prefix-list ppx1 172.16.22.0/24 set policy-options prefix-list ppx1 172.16.23.0/24 set policy-options prefix-list ppx1 172.16.24.0/24 set policy-options prefix-list ppx1 172.16.25.0/24 set policy-options prefix-list ppx1 172.16.26.0/24 set policy-options policy-statement p1 term t1 from family inet set policy-options policy-statement p1 term t1 from prefix-list ppx1 set policy-options policy-statement p1 term t1 then accept set routing-options autonomous-system 300
分步过程
下面的示例要求您在各个配置层级中进行导航。有关如何执行此操作的说明,请参阅 在配置模式下使用 CLI 编辑器Junos OS CLI 用户指南。
要配置设备 R1 的动态数据库:
进入动态数据库的配置模式。
content_copy zoom_out_mapuser@R1> configure dynamic Entering configuration mode [edit dynamic]
为从设备 R0 获知的接口地址创建前缀列表。
content_copy zoom_out_map[edit dynamic policy-options prefix-list dyn_prfx1] user@R1# set 172.16.1.0/24 user@R1# set 172.16.2.0/24 user@R1# set 172.16.3.0/24 user@R1# set 172.16.4.0/24 user@R1# set 172.16.5.0/24 user@R1# set 172.16.6.0/24 user@R1# set 172.16.7.0/24 user@R1# set 172.16.8.0/24
为从设备 R2 获知的接口地址创建前缀列表。
content_copy zoom_out_map[edit dynamic policy-options prefix-list dyn_prfx2] user@R1# set 172.16.2.0/24 user@R1# set 172.16.3.0/24 user@R1# set 172.16.4.0/24 user@R1# set 172.16.5.0/24 user@R1# set 172.16.6.0/24
配置路由策略。
content_copy zoom_out_map[edit dynamic policy-options policy-statement dyn_policy1] user@R1# set term t1 from prefix-list dyn_prfx1 user@R1# set term t1 then accept user@R1# set term t2 then reject user@R1# set term t1 from prefix-list dyn_prfx2 user@R1# set term t1 then accept user@R1# set term t2 then reject
分步过程
下面的示例要求您在各个配置层级中进行导航。有关如何执行此操作的说明,请参阅 在配置模式下使用 CLI 编辑器Junos OS CLI 用户指南。
要配置设备 R1 的标准数据库,请执行以下操作:
创建路由器接口。
content_copy zoom_out_map[edit interfaces] user@R1# set fe-1/2/0 unit 0 family inet address 10.0.0.2/30 user@R1# set fe-1/2/2 unit 0 family inet address 10.1.0.1/30 user@R1# set fe-1/2/1 unit 0 family inet address 172.16.4.2/24 user@R1# set fe-1/2/1 unit 0 family inet address 172.16.3.2/24 user@R1# set fe-1/2/1 unit 0 family inet address 172.16.2.2/24 user@R1# set fe-1/2/1 unit 0 family inet address 172.16.1.2/24 user@R1# set fe-1/2/1 unit 0 family inet address 172.16.5.2/24 user@R1# set fe-1/2/1 unit 0 family inet address 172.16.6.2/24 user@R1# set fe-1/2/1 unit 0 family inet address 172.16.7.2/24 user@R1# set fe-1/2/1 unit 0 family inet address 172.16.8.2/24 user@R1# set fe-1/2/1 unit 0 family inet address 172.16.9.2/24 user@R1# set fe-1/2/1 unit 0 family inet address 172.16.10.2/24 user@R1# set fe-1/2/3 unit 0 family inet address 172.16.2.2/24 user@R1# set fe-1/2/3 unit 0 family inet address 172.16.3.2/24 user@R1# set fe-1/2/3 unit 0 family inet address 172.16.4.2/24 user@R1# set fe-1/2/3 unit 0 family inet address 172.16.5.2/24 user@R1# set fe-1/2/3 unit 0 family inet address 172.16.6.2/24 user@R1# set lo0 unit 0 family inet address 192.168.0.2/32
创建引用动态数据库中的策略的路由策略。
content_copy zoom_out_map[edit policy-options] user@R1# set policy-statement dyn_policy1 dynamic-db user@R1# set policy-statement dyn_policy2 dynamic-db
配置与设备 R0 的 BGP 对等互连。
content_copy zoom_out_map[edit protocols bgp group to_r0] user@R1# set neighbor 10.0.0.1 peer-as 100
将动态数据库策略应用于与设备 R0 的 BGP 对等互连。
content_copy zoom_out_map[edit protocols bgp group to_r0] user@R1# set neighbor 10.0.0.1 import dyn_policy1 user@R1# set neighbor 10.0.0.1 export dyn_policy2
为从设备 R0 获知的前缀配置前缀列表。
content_copy zoom_out_map[edit policy-options prefix-list static_prfx2] user@R1# set 172.16.1.0/24 user@R1# set 172.16.2.0/24 user@R1# set 172.16.3.0/24 user@R1# set 172.16.4.0/24
为从设备 R2 获知的前缀配置前缀列表。
content_copy zoom_out_map[edit policy-options prefix-list static_prfx1] user@R1# set 172.16.2.0/24 user@R1# set 172.16.3.0/24 user@R1# set 172.16.4.0/24 user@R1# set 172.16.5.0/24
配置静态数据库策略。
content_copy zoom_out_map[edit policy-options policy-statement static_policy1] user@R1# set term t1 from prefix-list static_prfx1 user@R1# set term t1 then accept user@R1# set term t2 then reject [edit policy-options policy-statement static_policy2] user@R1# set term t1 from prefix-list static_prfx2 user@R1# set term t1 then accept user@R1# set term t2 then reject
配置与设备 R2 的 BGP 对等互连。
content_copy zoom_out_map[edit protocols bgp group to_R2] user@R1# set neighbor 10.1.0.2 peer-as 300
将静态数据库策略应用于与设备 R2 的 BGP 对等互连。
content_copy zoom_out_map[edit protocols bgp group to_R2] user@R1# set import static_policy1 user@R1# set export static_policy2
(可选)将路由器配置为在活动不间断路由切换后在指定时间段内或手动重新建立会话之前不重新建立 BGP 对等会话。
此语句对于动态路由策略特别有用,因为启用不间断活动路由 (NSR) 时,动态数据库不会与备份路由引擎同步。因此,如果切换到备份路由引擎,则切换时在主路由引擎上运行的导入和导出策略可能不再可用。因此,您可能希望防止在切换发生后立即自动重新建立 BGP 对等会话。
content_copy zoom_out_map[edit protocols bgp] user@R1# set group to_r0 idle-after-switch-over 300 user@R1# set group to_R2 idle-after-switch-over 300
配置自治系统 (AS) 编号。
content_copy zoom_out_map[edit routing-options] user@R1# set routing-options autonomous-system 200
结果
通过在动态数据库中输入配置模式命令,在show interfaces
标准数据库中输入show
配置模式中的 、 show protocols
show policy-options
和show routing-options
命令来确认配置。如果输出未显示预期的配置,请重复此示例中的说明,以便进行更正。
设备 R1 动态
[edit dynamic] user@R1# show policy-options { prefix-list dyn_prfx1 { 172.16.1.0/24; 172.16.2.0/24; 172.16.3.0/24; 172.16.4.0/24; 172.16.5.0/24; 172.16.6.0/24; 172.16.7.0/24; 172.16.8.0/24; } prefix-list dyn_prfx2 { 172.16.2.0/24; 172.16.3.0/24; 172.16.4.0/24; 172.16.5.0/24; 172.16.6.0/24; } policy-statement dyn_policy1 { term t1 { from { prefix-list dyn_prfx1; } then accept; } term t2 { then reject; } } policy-statement dyn_policy2 { term t1 { from { prefix-list dyn_prfx2; } then accept; } term t2 { then reject; } } }
设备 R1 标准
[edit] user@R1# 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 172.16.4.2/24; address 172.16.3.2/24; address 172.16.2.2/24; address 172.16.1.2/24; address 172.16.5.2/24; address 172.16.6.2/24; address 172.16.7.2/24; address 172.16.8.2/24; address 172.16.9.2/24; address 172.16.10.2/24; } } } fe-1/2/2 { unit 0 { family inet { address 10.1.0.1/30; } } } fe-1/2/3 { unit 0 { family inet { address 172.16.2.2/24; address 172.16.3.2/24; address 172.16.4.2/24; address 172.16.5.2/24; address 172.16.6.2/24; } } } lo0 { unit 0 { family inet { address 192.168.0.2/32; } } }
user@R1# show protocols bgp { group to_r0 { idle-after-switch-over 300; neighbor 10.0.0.1 { import dyn_policy1; export dyn_policy2; peer-as 100; } } group to_R2 { import static_policy1; export static_policy2; idle-after-switch-over 300; neighbor 10.1.0.2 { peer-as 300; } } }
user@R1# show policy-options prefix-list static_prfx1 { 172.16.2.0/24; 172.16.3.0/24; 172.16.4.0/24; 172.16.5.0/24; } prefix-list static_prfx2 { 172.16.1.0/24; 172.16.2.0/24; 172.16.3.0/24; 172.16.4.0/24; } policy-statement dyn_policy1 { dynamic-db; } policy-statement dyn_policy2 { dynamic-db; } policy-statement static_policy1 { term t1 { from { prefix-list static_prfx1; } then accept; } term t2 { then reject; } } policy-statement static_policy2 { term t1 { from { prefix-list static_prfx2; } then accept; } term t2 { then reject; } }
user@R1# show routing-options autonomous-system 200;
如果完成设备配置,请从配置模式输入 commit
。
验证
确认配置工作正常。
- 检查设备 R1 上配置的策略
- 检查从设备 R0 播发到设备 R1 的路由
- 检查设备 R1 从设备 R0 接收的路由
- 检查从设备 R2 播发到设备 R1 的路由
- 检查设备 R1 从设备 R2 接收的路由
- 检查设备 R1 向设备 R0 播发的路由
- 检查设备 R1 向设备 R2 播发的路由
检查设备 R1 上配置的策略
目的
验证设备 R1 的动态和静态策略是否有效。
操作
从设备 R1 中,输入 show policy
命令。
user@R1> show policy Configured policies: dyn_policy1 dyn_policy2 static_policy1 static_policy2 dyn_policy1 dyn_policy2
意义
动态策略被列出两次,因为它们配置了两次,即动态数据库中的第一次配置和集中配置。辅助配置位于引用动态数据库的静态数据库中,如下所示:
在动态数据库中配置
policy-statement dyn_policy1 { term t1 { from { prefix-list dyn_prfx1; } then accept; } term t2 { then reject; } } policy-statement dyn_policy2 { term t1 { from { prefix-list dyn_prfx2; } then accept; } term t2 { then reject; } }
从静态数据库引用
policy-statement dyn_policy1 { dynamic-db; } policy-statement dyn_policy2 { dynamic-db; }
检查从设备 R0 播发到设备 R1 的路由
目的
验证设备 R0 的路由策略是否正常工作。
操作
从设备 R0 中,输入命令,并使用 show route advertising-protocol bgp
设备 R1 的邻居地址。
user@R0> show route advertising-protocol bgp 10.0.0.2 inet.0: 28 destinations, 28 routes (28 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 172.16.1.0/24 Self I * 172.16.2.0/24 Self I * 172.16.3.0/24 Self I * 172.16.4.0/24 Self I * 172.16.5.0/24 Self I * 172.16.6.0/24 Self I * 172.16.7.0/24 Self I * 172.16.8.0/24 Self I * 172.16.9.0/24 Self I * 172.16.10.0/24 Self I * 10.0.0.0/30 Self I
意义
设备 R0 正在向设备 R1 发送预期的路由。
检查设备 R1 从设备 R0 接收的路由
目的
验证设备 R1 的导入路由策略是否正常工作。
操作
在设备 R1 中,输入命令,并使用 show route receive-protocol bgp
设备 R0 的邻居地址。
user@R1> show route receive-protocol bgp 10.0.0.1 inet.0: 35 destinations, 51 routes (35 active, 0 holddown, 4 hidden) Prefix Nexthop MED Lclpref AS path 172.16.1.0/24 10.0.0.1 100 I 172.16.2.0/24 10.0.0.1 100 I 172.16.3.0/24 10.0.0.1 100 I 172.16.4.0/24 10.0.0.1 100 I 172.16.5.0/24 10.0.0.1 100 I 172.16.6.0/24 10.0.0.1 100 I 172.16.7.0/24 10.0.0.1 100 I 172.16.8.0/24 10.0.0.1 100 I
意义
设备 R0 发送的某些路由未被设备 R1 接收。缺少路由 172.16.9.0/24、172.16.10.0/24 和 10.0.0.0/30。这是因为设备 R1 的导入策略(使用该语句应用于 import dyn_policy1
与设备 R0 的 BGP 对等会话)专门定义了仅限于以下路由的前缀列表:
prefix-list dyn_prfx1 { 172.16.1.0/24; 172.16.2.0/24; 172.16.3.0/24; 172.16.4.0/24; 172.16.5.0/24; 172.16.6.0/24; 172.16.7.0/24; 172.16.8.0/24; }
检查从设备 R2 播发到设备 R1 的路由
目的
验证设备 R2 的路由策略是否正常工作。
操作
在设备 R2 中,输入命令,并使用 show route advertising-protocol bgp
设备 R1 的邻居地址。
user@R2> show route advertising-protocol bgp 10.1.0.1 inet.0: 17 destinations, 17 routes (17 active, 0 holddown, 0 hidden) Prefix Nexthop MED Lclpref AS path * 172.16.2.0/24 Self I * 172.16.3.0/24 Self I * 172.16.4.0/24 Self I * 172.16.5.0/24 Self I * 172.16.6.0/24 Self I
意义
设备 R2 正在向设备 R1 发送预期的路由。
检查设备 R1 从设备 R2 接收的路由
目的
验证设备 R1 的导入路由策略是否正常工作。
操作
在设备 R1 中,输入命令,并使用 show route receive-protocol bgp
设备 R0 的邻居地址。
user@R1> show route receive-protocol bgp 10.1.0.2 inet.0: 35 destinations, 51 routes (35 active, 0 holddown, 4 hidden) Prefix Nexthop MED Lclpref AS path 172.16.2.0/24 10.1.0.2 300 I 172.16.3.0/24 10.1.0.2 300 I 172.16.4.0/24 10.1.0.2 300 I 172.16.5.0/24 10.1.0.2 300 I
意义
设备 R2 发送的路由之一未被设备 R1 接收。缺少路由 172.16.6.0/24。这是因为设备 R1 的导入策略(使用该语句应用于 import static_policy1
与设备 R2 的 BGP 对等会话)专门定义了仅限于以下路由的前缀列表:
prefix-list static_prfx1 { 172.16.2.0/24; 172.16.3.0/24; 172.16.4.0/24; 172.16.5.0/24; }
检查设备 R1 向设备 R0 播发的路由
目的
验证设备 R1 的导出路由策略是否正常工作。
操作
在设备 R1 中,输入命令,并使用 show route advertising-protocol bgp
设备 R0 的邻居地址。
user@R1> show route advertising-protocol bgp 10.0.0.1 inet.0: 35 destinations, 51 routes (35 active, 0 holddown, 4 hidden) Prefix Nexthop MED Lclpref AS path * 172.16.2.0/24 Self I * 172.16.3.0/24 Self I * 172.16.4.0/24 Self I * 172.16.5.0/24 Self I * 172.16.6.0/24 Self I
意义
也许出乎意料的是,设备 R1 未通过 BGP 从设备 R2 (172.16.6.0/24) 接收的路由仍然由设备 R1 通过 BGP 播发到设备 R0。发生这种情况有两个原因。第一个原因是路由 172.16.6.0/24 位于设备 R1 的路由表中,尽管是直接路由,如下所示:
user@R1> show route 172.16.6.0/24 protocol direct inet.0: 35 destinations, 51 routes (35 active, 0 holddown, 4 hidden) + = Active Route, - = Last Active, * = Both 172.16.6.0/24 *[Direct/0] 2d 22:51:41 > via fe-1/2/3.0
第二个原因是设备 R1 的导出策略(使用该语句应用于 export dyn_policy2
与设备 R0 的 BGP 对等会话)专门定义了仅限于以下路由的前缀列表:
prefix-list dyn_prfx2 { 172.16.2.0/24; 172.16.3.0/24; 172.16.4.0/24; 172.16.5.0/24; 172.16.6.0/24; }
请注意包含 172.16.6.0/24。
检查设备 R1 向设备 R2 播发的路由
目的
验证设备 R1 的导出路由策略是否正常工作。
操作
在设备 R1 中,输入命令,使用 show route advertising-protocol bgp
设备 R2 的邻居地址。
user@R1> show route advertising-protocol bgp 10.1.0.2 inet.0: 35 destinations, 51 routes (35 active, 0 holddown, 4 hidden) Prefix Nexthop MED Lclpref AS path * 172.16.1.0/24 Self I * 172.16.2.0/24 Self I * 172.16.3.0/24 Self I * 172.16.4.0/24 Self I
意义
设备 R1 正在向设备 R2 发送预期的路由。设备 R1 的导出策略(使用该语句应用于 export static_policy2
与设备 R2 的 BGP 对等会话)专门定义了仅限于以下路由的前缀列表:
prefix-list static_prfx2 { 172.16.1.0/24; 172.16.2.0/24; 172.16.3.0/24; 172.16.4.0/24; }