配置流监控
流监控应用可执行流量监控,并允许合法拦截两个路由器或交换机之间的流量。流量流可以由离线路由器或交换机被动监控,也可以由参与网络的路由器主动监控。
配置流监控接口
要在监控服务 PIC 上启用流监控,请在层次结构级别添加 mo-fpc/pic/port 语句 [edit interfaces] :
mo-fpc/pic/port {
unit logical-unit-number {
family inet {
address address {
destination address;
}
filter {
group filter-group-number;
input filter-name;
output filter-name;
}
sampling {
[ input output ];
}
}
}
multiservice-options {
(core-dump | no-core-dump);
(syslog | no-syslog);
flow-control-options {
down-on-flow-control;
dump-on-flow-control;
reset-on-flow-control;
}
}
}
指定流监控接口的物理和逻辑位置。不能使用 unit 0,因为它已被内部进程使用。指定源地址和目标地址。该 filter 语句允许您关联已为此目的配置的输入或输出过滤器或过滤器组。该 sampling 语句指定流量方向: input、 或 output两者。
该 multiservice-options 语句允许您配置与流监控接口相关的属性:
包含该
core-dump语句以启用 /var/tmp 中核心文件的存储。在 /var/log 中包含
syslog启用系统日志记录信息存储的语句。注意:用于监控服务接口的启动映像在层次结构级别指定
[edit chassis images pic]。您必须包括以下配置,以使流监控功能可作:[edit system] ntp { boot-server ntp.example.net; server 172.17.28.5; } processes { ntp enable; }
包含
flow-control-options用于配置流控制的语句。注意:当发生长时间的流量控制故障时,以及将设置配置为在长时间的流量控制期间生成核心转储时(通过将该选项与语句搭配
flow-control-options使用dump-on-flow-control),将生成多服务 PIC 管理守护程序核心文件。在这种情况下,看门狗功能会继续生成内核核心文件。
配置流监控属性
要配置流监控属性,请在层次结构级别包含[edit forwarding-options]该monitoring语句:
monitoring name { family inet { output { cflowd hostname port port-number; export-format format; flow-active-timeout seconds; flow-export-destination { collector-pic; } flow-inactive-timeout seconds; interface interface-name { engine-id number; engine-type number; input-interface-index number; output-interface-index number; source-address address; } } }
监控实例是在语句下 monitoring name 指定收集器信息的命名实体。以下部分介绍了可以配置的属性:
将流量定向到流监控接口
要将流量定向到流监控接口,请在层次结构级别包含[edit forwarding-options monitoring name output]该interface语句。默认情况下,Junos OS 会自动为 and engine-id engine-type 语句分配值:
engine-id— 监控接口位置。engine-type— 特定于平台的监控接口类型。
该 source-address 语句指定用于传输 cflowd 信息的流量源;您必须手动配置。如果为每个监控服务输出接口提供不同的 source-address 语句,则可以跟踪哪个接口处理了特定的 cflowd 记录。
默认情况下,该input-interface-index值是输入接口的 SNMP 索引。您可以通过包含特定值来覆盖默认值。和output-interface-index值input-interface-index将导出到 cflowd 版本 5 流格式中的字段中。
导出流
要将流量定向到流收集接口,请包含该 flow-export-destination 语句。有关流收集的更多信息,请参阅 主动流监控概述。
要配置 cflowd 版本号,请在层次结构级别包含export-format[edit forwarding-options monitoring name output]该语句。默认情况下,使用版本 5。版本 8 使路由器软件能够使用更广泛的标准聚合流信息,并减少 cflowd 流量。版本 8 聚合会定期(每隔几秒钟)对活动流以及允许流过期时执行。由于聚合是定期执行的,因此会忽略活动超时事件。
有关 cflowd 属性的详细信息,请参阅 启用流聚合。
配置流监控处于活动状态和非活动状态的时间段
要配置主动流量监控的时间段和闲置时间间隔,请在层次结构级别包括 flow-active-timeout [edit forwarding-options monitoring name output] and flow-inactive-timeout 语句:
该
flow-active-timeout语句指定活动流的流导出之间的时间间隔。如果收到最后一个数据包与上次导出流量之间的间隔超过配置的值,则导出流量。当流量持续时间较长时,需要此计时器来提供定期更新。活动超时设置使路由器能够将流的开始时间保留为常量,并定期发送 cflowd 报告。这反过来又允许收集器注册开始时间,并确定流量的存活持续时间是否长于配置的活动超时。
注意:在主动流监控中,cflowd 记录将在 60 秒的倍数且大于或等于配置的活动超时值的时间段后导出。例如,如果活动超时值为 90 秒,则以 120 秒的间隔导出 cflowd 记录。如果活动超时值为 150 秒,则以 180 秒的间隔导出 cflowd 记录,依此类推。
该
flow-inactive-timeout语句指定触发流导出的流的不活动时间间隔。如果当前时间与接收此流的最后一个数据包的时间之间的间隔超过配置的非活动超时值,则允许流过期。如果流停止传输的时间超过配置的非活动超时值,路由器或交换机会将其从流表中清除,并导出 cflowd 记录。因此,就 PIC 而言,流会被遗忘,如果相同的 5 元组再次出现,则会为其分配新的开始时间并被视为新流。
两个计时器都是必要的。需要使用活动超时设置来为长时间持续传输数据包的流量提供信息。非活动超时设置使路由器或交换机能够清除已变为非活动状态且可能浪费跟踪资源的流量。
路由器必须包含自适应服务、多服务或监控服务 PIC,and flow-active-timeout flow-inactive-timeout 语句才能生效。
示例:配置流监控
下面是配置为支持输入接口、输出监控服务接口以及导出到 cflowd 进行流分析的流监控属性示例。要完成配置,您还需要配置接口并设置虚拟专用网络 (VPN) 路由和转发 (VRF) 实例。有关 cflowd 的信息,请参阅 启用流聚合。
[edit forwarding-options]
monitoring group1 {
family inet {
output {
cflowd 192.168.245.2 port 2055;
export-format cflowd-version-5;
flow-active-timeout 60;
flow-inactive-timeout 30;
interface mo-4/0/0.1 {
engine-id 1;
engine-type 1;
input-interface-index 44;
output-interface-index 54;
source-address 192.168.245.1;
}
interface mo-4/1/0.1 {
engine-id 2;
engine-type 1;
input-interface-index 45;
output-interface-index 55;
source-address 192.168.245.1;
}
interface mo-4/2/0.1 {
engine-id 3;
engine-type 1;
input-interface-index 46;
output-interface-index 56;
source-address 192.168.245.1;
}
interface mo-4/3/0.1 {
engine-id 4;
engine-type 1;
input-interface-index 47;
output-interface-index 57;
source-address 192.168.245.1;
}
}
}
}
变更历史表
是否支持某项功能取决于您使用的平台和版本。使用 功能资源管理器 确定您的平台是否支持某个功能。
flow-control-options使用
dump-on-flow-control),将生成多服务 PIC 管理守护程序核心文件。