GithubHelp home page GithubHelp logo

bigomby / rsflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from redborder/f2k

3.0 2.0 0.0 966 KB

Dump Netflow data to a Kafka topic using JSON

Home Page: https://bigomby.github.io/rsflow

License: GNU Affero General Public License v3.0

Makefile 0.46% C 85.96% Shell 6.20% C++ 4.14% Rust 3.25%
netflow json kafka librdkafka rust

rsflow's Introduction

Build Status

Kafka Netflow

Overview

Simple service to dump collected Netflow V5/V9/IPFIX traffic to a Kafka topic.

kafka-netflow is based on redBorder/f2k, but aims to provide a more flexible way to manage sensors.

Differences with f2k

While f2k uses static JSON file to store sensors configuration, kafka-netflow will use an external service to dynamically store this information. This approach makes possible to add, remove, or update sensors using a REST API instead of modify the configuration file and restarting the service.

Zookeeper support is removed since sensors information (along with the Netflow templates) will be stored on the external service.

Status

Currently, kafka-netflow uses a new sensor database module which has been rewritted in Rust. This new module allows to use an external service to store sensors information, but it has not been implemented yet. Sensor database are still a static JSON file, but it will change in the future.

This project is currently WIP. The first release will be compatible with f2k but without support for Zookeeper.

Installing

Requirements

  • Rust nightly (expected to work with stable Rust in the future)
  • gcc
  • Makefile
  • udns
  • jansson
  • librdkafka
  • GeoIP
  • libpcap

Compiling

./configure
make dynamic-sensors
make
make install

Usage

Basic usage

The most important configuration parameters are:

  • Input/output parameters:

    • --kafka=127.0.0.1@netflow, broker@topic to send netflow
    • --collector-port=2055, Collector port to listen netflow
  • Configuration

    • --rb-config=/etc/sensors_db.json, file with sensors config. File format is detailed on the next section.

Sensors database file

You need to specify each sensor you want to read netflow from in a JSON file:

{
  "sensors_networks": {
    "4.3.2.1": {
      "observations_id": {
        "1": {
          "enrichment": {
            "sensor_ip": "4.3.2.1",
            "sensor_name": "flow_test",
            "observation_id": 1
          }
        }
      }
    }
  }
}

With this file, you will be listening for netflow coming from 4.3.2.1 (this could be a network too, 4.3.2.0/24), and the JSON output will be sent with that sensor_ip, sensor_name and observation_id keys.

Others configuration parameters

Template cache

You can specify a folder to save/load templates using --template-cache=/var/kafka-netflow/templates.

Multi-thread

--num-threads=N can be used to specify the number of netflow processing threads.

librdkafka options

All librdkafka options. can be used using -X parameter. The argument will be passed directly to librdkafka config, so you can use whatever config you need.

Recommended options are:

  • -X=socket.max.fails=3,
  • -X=delivery.report.only.error=true,

Long flow separation

Use --separate-long-flows if you want to divide flow with duration>60s into minutes. For example, if the flow duration is 1m30s, kafka-netflow will send 1 message containing 2/3 of bytes and pkts for the minute, and 1/3 of bytes and pkts to the last 30 seconds, like if we had received 2 different flows.

(see Test 0017 for more information about how flow are divided)

Geo information

kafka-netflow can add geographic information if you specify Maxmind GeoLite Databases location using:

  • --as-list=/var/GeoIP/asn.dat,
  • --country-list=/var/GeoIP/country.dat,

Names resolution

You can include more flow information, like many object names, with the option --hosts-path=/opt/rb/etc/objects/. This folder needs to have files with the provided names in order to kafka-netflow read them.

Mac vendor information (mac_vendor)

With --mac-vendor-list=mac_vendors kafka-netflow can translate flow source and destination macs, and they will be sending in JSON output as in_src_mac_name, out_src_mac_name, and so on.

The file mac_vendors should be like:

FCF152|Sony Corporation
FCF1CD|OPTEX-FA CO.,LTD.
FCF528|ZyXEL Communications Corporation

And you can generate it using make manuf, that will obtain it automatically from IANA Registration Authority.

Applications/engine ID (applications, engines)

kafka-netflow can translate applications and engine ID if you specify a list with them, like:

  • <hosts-path>/engines

    None            0
    IANA-L3         1
    PANA-L3         2
    IANA-L4         3
    PANA-L4         4
    ...
    
  • <hosts-path>/applications

    3com-amp3                 50332277
    3com-tsmux                50331754
    3pc                       16777250
    914c/g                    50331859
    ...
    

Hosts, domains, vlan (hosts, http_domains, vlans)

You can include more information about the flow source and destination ( src_name and dst_name) using a hosts list, using the same format as /etc/hosts. The same can be used with files vlan, domains, macs.

Netflow probe nets

You can specify per netflow probe home nets, so they will be taking into account when solving client/target IP.

You could specify them using home_nets:

"sensors_networks": {
  "4.3.2.0/24": {
    "2055": {
      "sensor_name": "test1",
      "sensor_ip": "",
      "home_nets": [{
          "network": "10.13.30.0/16",
          "network_name": "users"
        },
        {
          "network": "2001:0428:ce00:0000:0000:0000:0000:0000/48",
          "network_name": "users6"
        }
      ],
    }
  }
}

DNS

f2k can make reverse DNS in order to obtain some hosts names. To enable them, you must use:

  • enable-ptr-dns, general enable
  • dns-cache-size-mb, DNS cache to not repeat PTR queries
  • dns-cache-timeout-s, Entry cache timeout

rsflow's People

Contributors

bigomby avatar eugpermar avatar

Stargazers

Misha Komarovskiy avatar  avatar  avatar

Watchers

James Cloos avatar  avatar

rsflow's Issues

Installation error on CentOS 7.5

Getting an error when I try to compile this on CentOS 7.5:

[sysadmin@netflow-queue rsflow]$ ./configure
checking for OS or distribution... ok (Linux)
checking for C compiler from CC env... failed
checking for gcc (by command)... ok
checking executable ld... ok
checking executable nm... ok
checking executable objdump... ok
checking executable strip... ok
checking for pkgconfig (by command)... ok
checking for install (by command)... ok
checking for __atomic_32 (by compile)... ok
checking for __atomic_64 (by compile)... ok
checking for socket (by compile)... ok
checking for librd (by pkg-config)... failed
checking for librd (by compile)... failed (fail)
checking for pcap (by pkg-config)... failed
checking for pcap (by compile)... failed (fail)
checking for librdkafka (by pkg-config)... failed
checking for librdkafka (by compile)... failed (fail)
checking for rb_mac_vendor (by pkg-config)... failed
checking for rb_mac_vendor (by compile)... failed (fail)
checking for geoip (by pkg-config)... failed
checking for geoip (by compile)... failed (fail)
checking for udns (by pkg-config)... failed
checking for udns (by compile)... failed (fail)
checking for HAVE_JSON (by pkg-config)... failed
checking for HAVE_JSON (by compile)... failed (fail)
checking for optreset (by compile)... failed (disable)
checking for pthread (by pkg-config)... failed
checking for pthread (by compile)... ok
checking for pthread_setaffinity_np (by compile)... failed (disable)
checking for sin6_len (by compile)... failed (disable)
checking for netfilter (by pkg-config)... failed
checking for netfilter (by compile)... failed (disable)
checking for sctp (by compile)... failed (disable)
checking for pcap_next_ex (by compile)... failed (disable)
checking for pf_ring (by pkg-config)... failed
checking for pf_ring (by compile)... failed (disable)

###########################################################

Configure failed

###########################################################

Accumulated failures:

###########################################################
librd ()
module: f2k
action: fail
reason:
compile check failed:
CC: CC
flags: -lrd -lpthread -lz -lrt
gcc -Wno-missing-field-initializers -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -O2 -g -Wcast-qual -Wunused -Wextra -Wdisabled-optimization -Wshadow -Wmissing-declarations -Wundef -Wswitch-default -Wmissing-include-dirs -Wstrict-overflow=5 -Winit-self -Wlogical-op -Wcast-align -Wdisabled-optimization -DND EBUG -D_GNU_SOURCE -DFORTIFY_SOURCE=2 -Wall -Werror -lrd -lpthread -lz -lrt _mkltmpFaKPvT.c -o _mkltmpFaKPvT.c.o :
_mkltmpFaKPvT.c:1:22: fatal error: librd/rd.h: No such file or directory
#include <librd/rd.h>
^
compilation terminated.
source: #include <librd/rd.h>

pcap ()
module: f2k
action: fail
reason:
compile check failed:
CC: CC
flags: -lpcap
gcc -Wno-missing-field-initializers -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -O2 -g -Wcast-qual -Wunused -Wextra -Wdisabled-optimization -Wshadow -Wmissing-declarations -Wundef -Wswitch-default -Wmissing-include-dirs -Wstrict-overflow=5 -Winit-self -Wlogical-op -Wcast-align -Wdisabled-optimization -DND EBUG -D_GNU_SOURCE -DFORTIFY_SOURCE=2 -Wall -Werror -lpcap _mkltmp7r040a.c -o _mkltmp7r040a.c.o :
/usr/bin/ld: cannot find -lpcap
collect2: error: ld returned 1 exit status
source:

librdkafka ()
desc: librdkafka is available at http://github.com/edenhill/librdkafka.
module: f2k
action: fail
reason:
compile check failed:
CC: CC
flags: -lrdkafka -lpthread -lz
gcc -Wno-missing-field-initializers -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -O2 -g -Wcast-qual -Wunused -Wextra -Wdisabled-optimization -Wshadow -Wmissing-declarations -Wundef -Wswitch-default -Wmissing-include-dirs -Wstrict-overflow=5 -Winit-self -Wlogical-op -Wcast-align -Wdisabled-optimization -DND EBUG -D_GNU_SOURCE -DFORTIFY_SOURCE=2 -Wall -Werror -lrdkafka -lpthread -lz _mkltmpnVfPuZ.c -o _mkltmpnVfPuZ.c.o :
/usr/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
source: #include <librdkafka/rdkafka.h>

rb_mac_vendor (HAVE_RB_MAC_VENDORS)
module: f2k
action: fail
reason:
compile check failed:
CC: CC
flags: -lrb_mac_vendors
gcc -Wno-missing-field-initializers -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -O2 -g -Wcast-qual -Wunused -Wextra -Wdisabled-optimization -Wshadow -Wmissing-declarations -Wundef -Wswitch-default -Wmissing-include-dirs -Wstrict-overflow=5 -Winit-self -Wlogical-op -Wcast-align -Wdisabled-optimization -DND EBUG -D_GNU_SOURCE -DFORTIFY_SOURCE=2 -Wall -Werror -lrb_mac_vendors _mkltmpyZDtYf.c -o _mkltmpyZDtYf.c.o :
_mkltmpyZDtYf.c:1:28: fatal error: rb_mac_vendors.h: No such file or directory
#include <rb_mac_vendors.h>
^
compilation terminated.
source: #include <rb_mac_vendors.h>

geoip (HAVE_GEOIP)
module: f2k
action: fail
reason:
compile check failed:
CC: CC
flags: -lGeoIP
gcc -Wno-missing-field-initializers -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -O2 -g -Wcast-qual -Wunused -Wextra -Wdisabled-optimization -Wshadow -Wmissing-declarations -Wundef -Wswitch-default -Wmissing-include-dirs -Wstrict-overflow=5 -Winit-self -Wlogical-op -Wcast-align -Wdisabled-optimization -DND EBUG -D_GNU_SOURCE -DFORTIFY_SOURCE=2 -Wall -Werror -lGeoIP _mkltmpWXtKLL.c -o _mkltmpWXtKLL.c.o :
_mkltmpWXtKLL.c:1:19: fatal error: GeoIP.h: No such file or directory
#include <GeoIP.h>
^
compilation terminated.
source: #include <GeoIP.h>
void *f();void *f(){return GeoIP_org_by_ipnum;}
void *g();void *g(){return GeoIP_org_by_ipnum_v6;}

udns (HAVE_UDNS)
module: f2k
action: fail
reason:
compile check failed:
CC: CC
flags: -ludns
gcc -Wno-missing-field-initializers -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -O2 -g -Wcast-qual -Wunused -Wextra -Wdisabled-optimization -Wshadow -Wmissing-declarations -Wundef -Wswitch-default -Wmissing-include-dirs -Wstrict-overflow=5 -Winit-self -Wlogical-op -Wcast-align -Wdisabled-optimization -DND EBUG -D_GNU_SOURCE -DFORTIFY_SOURCE=2 -Wall -Werror -ludns _mkltmp67AQKc.c -o _mkltmp67AQKc.c.o :
_mkltmp67AQKc.c:1:18: fatal error: udns.h: No such file or directory
#include <udns.h>
^
compilation terminated.
source: #include <udns.h>
void *f();void *f(){return 0;}

HAVE_JSON (HAVE_JSON)
module: f2k
action: fail
reason:
compile check failed:
CC: CC
flags: -ljansson
gcc -Wno-missing-field-initializers -Wall -Wsign-compare -Wfloat-equal -Wpointer-arith -O2 -g -Wcast-qual -Wunused -Wextra -Wdisabled-optimization -Wshadow -Wmissing-declarations -Wundef -Wswitch-default -Wmissing-include-dirs -Wstrict-overflow=5 -Winit-self -Wlogical-op -Wcast-align -Wdisabled-optimization -DND EBUG -D_GNU_SOURCE -DFORTIFY_SOURCE=2 -Wall -Werror -ljansson _mkltmpnF3ZW0.c -o _mkltmpnF3ZW0.c.o :
_mkltmpnF3ZW0.c:1:21: fatal error: jansson.h: No such file or directory
#include <jansson.h>
^
compilation terminated.
source: #include <jansson.h>

###########################################################

Installing the following packages might help:

###########################################################
sudo apt-get install librdkafka-dev

I think I installed pretty much all the dependencies but not sure what is wrong. I installed librdkafka using yum but it is even complaing about that. Any clues for me?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.