示例:在具有 MS-MIC 和 MS-MPC 的 MX 系列路由器上配置流监控
此示例说明如何配置 Junos Traffic Vision,以便在带有 MS-MIC 和 MS-MPC 的 MX 系列路由器上进行流监控,并包含以下部分:
在 MS-MIC 上配置流监视
CLI 快速配置
要快速配置此示例,请复制以下命令,将其粘贴到文本文件中,删除所有换行符,更改详细信息,以便与网络配置匹配,然后将命令复制并粘贴到 [编辑] 层次结构级别的 CLI 中。
您可以按照相同的过程并使用相同的配置在 MS-MPC 上配置流监视。
启用服务接口卡
set interfaces ms-2/0/0 unit 0 family inet
配置模板和计时器
set services flow-monitoring version9 template template1 set services flow-monitoring version9 template template1 flow-active-timeout 120 set services flow-monitoring version9 template template1 flow-inactive-timeout 60 set services flow-monitoring version9 template template1 ipv4-template set services flow-monitoring version9 template template1 template-refresh-rate packets 100 set services flow-monitoring version9 template template1 template-refresh-rate seconds 600 set services flow-monitoring version9 template template1 option-refresh-rate packets 100 set services flow-monitoring version9 template template1 option-refresh-rate seconds 600
配置服务集属性
set services service-set ss1 jflow-rules sampling set services service-set ss1 sampling-service service-interface ms-2/0/0.0
配置转发选项和流服务器设置
set forwarding-options sampling input rate 10 set forwarding-options sampling input run-length 18 set forwarding-options sampling family inet output flow-server 10.44.4.3 port 1055 set forwarding-options sampling family inet output flow-server 10.44.4.3 version9 template template1 set forwarding-options sampling family inet output interface ms-2/0/0.0 source-address 203.0.113.1
分步过程
下面的示例要求您在各个配置层级中进行导航。有关 CLI 导航的信息,请参阅 CLI 用户指南中的在配置模式下使用 CLI 编辑器。
MS 接口必须配置可访问收集器的家族类型。如果可通过 IPv4 访问采样流量的收集器,那么即使仅对 IPv6 和 MPLS 流量进行采样,也必须在 MS 接口下设置家族 inet。
配置服务接口。
[edit interfaces] user@router1# set interfaces ms-2/0/0 unit 0 family inet user@router1# set interfaces ms-2/0/0 unit 1 family inet6 user@router1# set interfaces ms-2/0/0 unit 2 family mpls
配置模板属性和导出策略计时器。
[edit services] user@router1# set flow-monitoring version9 template template1 user@router1# set flow-monitoring version9 template template1 flow-active-timeout 120 user@router1# set flow-monitoring version9 template template1 flow-inactive-timeout 60 user@router1# set flow-monitoring version9 template template1 ipv4-template user@router1# set flow-monitoring version9 template template1 template-refresh-rate packets 100 user@router1# set flow-monitoring version9 template template1 template-refresh-rate seconds 600 user@router1# set flow-monitoring version9 template template1 option-refresh-rate packets 100 user@router1# set flow-monitoring version9 template template1 option-refresh-rate seconds 600
表 1:此层级关键配置语句的快速参考 配置语句
描述
flow-active-timeout配置导出活动流的时间间隔(以秒为单位)。
范围为 10 到 600 秒,默认值为 60 秒。
flow-inactive-timeout配置非活动时间间隔(以秒为单位),在此时间间隔之后,流将被标记为非活动。
范围为 10 到 600 秒,默认值为 60 秒。
ipv4-template | ipv6-template | mpls-template | mpls-ipv4-template
指定模板用于的流量类型。
template-refresh-rate指定模板刷新率,可以是数据包数(范围为 1 到 480,000,默认值为 4800),要么以秒为单位(范围为 10 到 600,默认值为 600)。
由于流量生成器和流量收集器之间的通信是单向通信,因此流量生成器必须定期向流量收集器发送有关模板定义的更新。为此语句配置的值控制此类更新的频率。
option-refresh-rate将选项刷新率指定为数据包数(范围为 1 到 480,000,默认值为 4800)或以秒为单位(范围为 10 到 600,默认值为 60)。
配置服务集属性。
[edit services] user@router1# set service-set ss1 jflow-rules sampling user@router1# set service-set ss1 sampling-service service-interface ms-2/0/0.0
表 2:此层级配置语句的快速参考 配置语句
描述
sampling配置服务集以处理采样/流监视活动。
service-interface指定与服务集关联的服务接口。
此处配置的接口应与在 中配置的
[edit forwarding-options sampling family inet output]接口匹配。另请注意,接口不应与任何其他服务集相关联。配置转发选项和流服务器属性。
[edit forwarding-options] user@router1# set sampling input rate 10 user@router1# set sampling input run-length 18 user@router1# set sampling family inet output flow-server 10.44.4.3 port 1055 user@router1# set sampling family inet output flow-server 10.44.4.3 version9 template template1 user@router1# set sampling family inet output interface ms-2/0/0.0 source-address 203.0.113.1
注意:您可以通过定义采样实例在全局级别(如本例所示)或在 FPC 级别指定采样参数。要定义采样实例,请在
[edit forwarding-options sampling]层次结构级别包含语句,sampling-instance并在层次结构级别包含instance语句[edit chassis fpc number],以便将采样实例与 FPC 相关联。在[edit forwarding-options sampling instance instance]层次结构级别下,还必须包括此步骤中介绍的input和output配置。表 3:此层次结构级别关键配置语句的快速参考 配置语句
描述
rate要采样的数据包数的比率。例如,如果指定速率 10,则每 10 个数据包(10 个数据包中有 1 个数据包)进行采样。
范围为 1 到 16000000(16M)。
run-length初始触发事件之后的样本数。这样就可以按照已采样的数据包对数据包进行采样。
范围为 0 到 20,默认值为 0。
flow-server一个主机系统,用于使用版本 9 格式收集采样流。
source-address用作导出数据包源地址的 IPv4 地址。
结果
在配置模式下,输入show chassis fpc 2show interfaces、和show forwarding-options命令,以确认您的配置。如果输出未显示预期的配置,请重复此示例中的说明以更正配置。
user@router1# show interfaces
ms-2/0/0 {
unit 0 {
family inet;
}
}
user@router1# show services
flow-monitoring {
version9 {
template template1 {
flow-active-timeout 120;
flow-inactive-timeout 60;
template-refresh-rate {
packets 100;
seconds 600;
}
option-refresh-rate {
packets 100;
seconds 600;
}
ipv4-template;
}
}
}
service-set ss1 {
jflow-rules {
sampling;
}
sampling-service {
service-interface ms-2/0/0.0
}
}
user@router1# show forwarding-options
sampling {
input {
rate 10;
run-length 18;
}
family inet {
output {
flow-server 10.44.4.3 {
port 1055;
version9 {
template {
template1;
}
}
}
interface ms-2/0/0.0 {
source-address 203.0.113.1;
}
}
}
}
硬件和软件要求
此示例要求 MX 系列路由器具备以下条件:
在其上运行 Junos OS 13.2 版。
其中安装了 MS-MIC。
MS-MIC 和 MS-MPC 上的 Junos Traffic Vision 支持
Junos Traffic Vision(以前称为 Jflow)是 MS-MIC 和 MS-MPC 上提供的计费服务。Junos Traffic Vision 使用户能够跟踪在 MS-MIC 或 MS-MPC 上接收的数据包,并生成包含数据包源地址、数据包的目标地址、数据包和字节计数等信息的流记录。Junos Traffic Vision 实施不会中断流量,而是创建传入数据包的副本,并将该副本发送到服务接口卡,以便分析信息并维护记录。
从版本 13.2 开始,Junos OS 扩展提供程序软件包预安装在多服务 MIC 和 MPC(MS-MIC 和 MS-MPC)上。 adaptive-services 层次结构级别的配置 [edit chassis fpc number pic number] 在这些卡上预先配置。
在 MS-MIC 或 MS-MPC 上配置 Junos Traffic Vision 之前,必须创建已 sample 配置为作的防火墙过滤器,并将其应用于要监控流量的接口。Junos Traffic Vision 实现中的流收集器是用于收集流记录的设备。流收集器通常部署在网络外部。
有关配置防火墙过滤器的详细信息,请参阅《Junos OS 防火墙过滤器配置指南。
在 MS-MIC 和 MS-MPC 上,Junos OS 支持 Junos Traffic Vision 版本 9 (v9)。Junos Traffic Vision v9 支持对 IPv4、IPv6 和 MPLS 流量进行采样。服务接口卡对于 v9 的实施至关重要,因此通常称为基于 PIC 的监控。
您可以配置流记录在服务接口卡上的存储最长时间。定义模板时配置的活动超时和非活动超时值控制将流记录导出到收集器。MS-MIC 最多可存储 1400 万条流量记录,而 MS-MPC 每个 NPU 最多可存储 3000 万条流量。
在使用 Junos OS 扩展提供程序包的 Junos Traffic Vision 配置中,在启动流监控后修改以下语句将导致所有现有流过期:
[edit forwarding-options sampling instance instance-name family (inet |inet6 |mpls) output]在和[edit forwarding-options sampling family (inet |inet6 |mpls) output]层次结构级别:flow-server ip-addressflow-server port port-numberflow-server template template
[edit services flow-monitoring version9 template template-name mpls-ipv4-template]在和[edit services flow-monitoring version9 template template-name mpls-template]层次结构级别:label-position
由于这些更改可能会中断正在进行的流监控,因此建议您在设备上启动流监控后不要更改这些值。在进行流监控时对这些配置语句所做的更改仅适用于新创建的流。
另请注意,这些更改不会中断使用 Junos OS 第 2 层服务包运行 Jflow 配置的设备上的流量监控。但是,即使采用基于第 2 层服务包的配置,更改也只会应用于新创建的流。现有流继续使用初始设置。
在 MS-MIC 和 MS-MPC 上配置 Junos Traffic Vision 时,当采样流的目标可通过多条路径到达时,下一跃点地址和传出接口会错误地显示在 IPv4 和 IPv6 流记录中。
验证
确认配置工作正常。
验证 Junos Traffic Vision 配置
目的
验证路由器上是否已启用 Junos Traffic Vision。
行动
在作模式下,输入 show services accounting status 命令。
user@router1> show services accounting status Service Accounting interface: ms-2/0/0 Export format: 9, Route record count: 2093 IFL to SNMP index count: 35, AS count: 2 Configuration set: Yes, Route record set: Yes, IFL SNMP map set: Yes
意义
显示配置监控的服务接口,并提供有关所用导出格式(本例中为版本 9)的信息。
查看流详细信息
目的
查看为流监控配置的接口上的流详细信息。
行动
在作模式下,输入 show services accounting flow 命令。
user@router1> show services accounting flow
Flow information
Service Accounting interface: ms-2/0/0, Local interface index: 229
Flow packets: 220693, Flow bytes: 24276230
Flow packets 10-second rate: 99, Flow bytes 10-second rate: 10998
Active flows: 10, Total flows: 12
Flows exported: 199, Flows packets exported: 718
Flows inactive timed out: 2, Flows active timed out: 199
查看服务接口上发生的错误的详细信息
目的
查看为流监控配置的接口上的错误详细信息(如果有)。
行动
在作模式下,输入 show services accounting errors 命令。
user@router1> show services accounting errors
Error information
Service Accounting interface: ms-2/0/0
Service sets dropped: 0, Active timeout failures: 0
Export packet failures: 0, Flow creation failures: 0
Memory overload: No