NetFlow的配置

NetFlow介绍

NetFlow允许基于设备接口收集网络流量的统计信息,它提供了在数据进入或离开接口时收集IP网络流量的能力。通过分析NetFlow提供的数据,网络管理员可以确定流量的源和目的地、服务类别以及拥塞的原因。

NetFlow通常使用UDP协议进行导出,并使用NetFlow Collector进行收集。NetFlow Collector的IP地址和目标UDP端口必须在发送设备(FortiGate)上进行配置。标准的NetFlow UDP端口为2055。

在FortiGate中,根据netflow-sampler监控的接口,发送所有此接口相关的会话信息,无法设置NetFlow的接口采样率。

在任何接口上配置NetFlow都不会影响NP芯片的加速功能。

NetFlow配置

NetFlow发送配置

未开启VDOM的配置

config system netflow
    set collector-ip <ip>
    set collector-port <port>
    set source-ip <ip>
    set active-flow-timeout <integer>
    set inactive-flow-timeout <integer>
    set template-tx-timeout <integer>
    set template-tx-counter <integer>
end
参数名称 参数说明
collector-ip [ip] NetFlow collector的IPv4或IPv6地址(IPv6在7.2.0 GA后支持)
collector-port [port] NetFlow collector用于接收NetFlow流量的端口,默认为2055
source-ip [ip] 指定FortiGate发送NetFlow流量的源IP,默认根据路由出接口指定源IP
active-flow-timeout [integer] 报告活动中的会话NetFlow信息的间隔,默认为30分钟,范围1~60
inactive-flow-timeout [integer] 报告已结束的会话NetFlow信息的间隔,默认为15秒,范围10~600
template-tx-timeout [integer] 模板数据流的发送间隔,默认30分钟,范围1~1440
template-tx-counter [integer] 数据流记录的产生计数,达到这个计数后也会发送模板数据流到collector,默认为20,范围10~6000

开启多VDOM的配置

config vdom
    edit <vdom>
        config system vdom-netflow
            set vdom-netflow enable
            set collector-ip <ip>
            set collector-port <port>
            set source-ip <ip>
        end
    next
end

NetFlow采样器配置

config system interface
    edit <interface>
        set netflow-sampler {disable | tx | rx | both}
    next
end
参数名称 参数说明
disable 接口下关闭NetFlow采样,默认配置
tx 采样此接口发送的流量
rx 采样此接口接收的流量
both 同时采样此接口发送和接收的流量

配置验证

  1. 如果在NetFlow上无法查询到FortiGate的NetFlow数据,可以在FortiGate上抓包查看NetFlow数据是否已发送,如下图所示。

    diagnose sniffer packet 'host <collector-ip> and port <collector-port>' 6 0 l
    

    image-20230829154733201

  2. NetFlow功能通过FortiGate的sflow进程工作,通过以下命令,可以看到Netflow的工作状态。

    FortiGate # diagnose test application sflowd 3
    
    ===== Netflow Vdom Configuration =====
    Global collector:172.22.5.41:[2055] source ip:  active-timeout(seconds):1800 inactive-timeout(seconds):15
    ____ vdom: root, index=0, is master, collector: disabled (use global config) (mgmt vdom) 
       |_ coll_ip:172.22.5.41:2055,src_ip:172.22.5.19
       |_ seq_num:301 pkts/time to next template: 7/1259
       |_ exported: Bytes:114028124, Packets:322978, Sessions:13457 Flows:13494
       |_ active_intf: 1
       |____ interface:wan2 sample_direction:both device_index:6 snmp_index:2
    
  3. 查看流量会话是否匹配NetFlow,如下所示,会话被打上了NetFlow-reply方向的标记。

    # diagnose sys session list
    session info: proto=1 proto_state=00 duration=1732 expire=59 timeout=0 flags=00000000 socktype=0 sockport=0 av_idx=0 use=3
    origin-shaper=
    reply-shaper=
    per_ip_shaper=
    class_id=0 ha_id=0 policy_dir=0 tunnel=/ vlan_cos=0/255
    state=may_dirty netflow-origin netflow-reply
    statistic(bytes/packets/allow_err): org=145572/1733/1 reply=145572/1733/1 tuples=2
    tx speed(Bps/kbps): 83/0 rx speed(Bps/kbps): 83/0
    orgin->sink: org pre->post, reply pre->post dev=5->26/26->5 gwy=10.39.252.244/172.16.200.55
    hook=post dir=org act=snat 172.16.200.55:61290->8.8.8.8:8(10.39.252.243:61290)
    hook=pre dir=reply act=dnat 8.8.8.8:61290->10.39.252.243:0(172.16.200.55:61290)
    misc=0 policy_id=1 auth_info=0 chk_client_info=0 vd=0
    serial=00001298 tos=ff/ff app_list=0 app=0 url_cat=0
    sdwan_mbr_seq=0 sdwan_service_id=0
    rpdb_link_id=00000000 rpdb_svc_id=0 ngfwid=n/a
    npu_state=0x040000
    no_ofld_reason:  non-npu-intf
    total session 1
    

Copyright © 2023 Fortinet Inc. All rights reserved. Powered by Fortinet TAC Team.
📲扫描下方二维码分享此页面👇
该页面修订于: 2023-09-12 15:24:08

results matching ""

    No results matching ""