|
1 |
| -# Usage - nflow-generator |
| 1 | +# manflow |
2 | 2 |
|
3 |
| -[](https://github.com/nerdalert/nflow-generator/actions/workflows/image-build.yml) |
| 3 | +Netflow generator |
4 | 4 |
|
5 |
| -This program generates mock netflow (v5) data that can be used to test netflow collector programs. |
6 |
| -The program simulates a router that is exporting flow records to the collector. |
7 |
| -It is useful for determining whether the netflow collector is operating and/or receiving netflow datagrams. |
| 5 | +Documentation: https://aviatrix.atlassian.net/wiki/spaces/copconf/pages/1913815177/manflow+netflow+generator |
8 | 6 |
|
9 |
| -nflow-generator generates several netflow datagrams per second, each with 8 or 16 records for varying kinds of traffic (HTTP, SSH, SNMP, DNS, MySQL, and many others.) |
| 7 | +## Usage |
10 | 8 |
|
11 |
| -### Docker Image Run (Easiest) |
| 9 | +Using following `flowConfig.json` file: |
12 | 10 |
|
13 |
| -Simply run in a container and pass any arguments at runtime. Below is an example passing the `--help` flag: |
14 |
| - |
15 |
| -``` |
16 |
| -docker run -it --rm networkstatic/nflow-generator --help |
17 |
| -# or podman/quay repos |
18 |
| -podman run -it --rm /quay.io/networkstatic/nflow-generator --help |
19 |
| -``` |
20 |
| - |
21 |
| -To generate mock flow data simply add the target IP and port: |
22 |
| - |
23 |
| -``` |
24 |
| -docker run -it --rm networkstatic/nflow-generator -t <ip> -p <port> |
25 |
| -# or podman/quay repos |
26 |
| -podman run -it --rm /quay.io/networkstatic/nflow-generator -t <ip> -p <port> |
| 11 | +```json |
| 12 | +{ |
| 13 | + "seed": 1, |
| 14 | + "flow_timeout": 10, |
| 15 | + "collector_ip": "10.0.0.11", |
| 16 | + "collector_port": 31283, |
| 17 | + "hosts": [ |
| 18 | + { |
| 19 | + "ip": "10.0.0.103", |
| 20 | + "name": "gw1" |
| 21 | + } |
| 22 | + ], |
| 23 | + "flows": [ |
| 24 | + { |
| 25 | + "src_addr": "10.14.0.0", |
| 26 | + "dst_addr": "10.0.1.0", |
| 27 | + "dst_port": "80", |
| 28 | + "hops": ["gw1"], |
| 29 | + "count": 1 |
| 30 | + } |
| 31 | + ] |
| 32 | +} |
27 | 33 | ```
|
28 | 34 |
|
29 |
| -### Download the binary |
30 |
| - |
31 |
| -You can download the Linux binary here [nflow-generator-x86_64-linux](https://github.com/nerdalert/nflow-generator/blob/master/binaries/nflow-generator-x86_64-linux). |
32 |
| -### Build |
33 |
| - |
34 |
| -Install [Go](http://golang.org/doc/install), then: |
| 35 | +Run following commands |
35 | 36 |
|
36 |
| - git clone https://github.com/nerdalert/nflow-generator.git |
37 |
| - cd nflow-generator |
38 |
| - go build |
39 |
| - |
40 |
| -Go build will leave a binary in the root directory that can be run. |
41 |
| - |
42 |
| -### RUN |
43 |
| - |
44 |
| -Feed it the target collector and port, and optional "false-index" flag: |
45 |
| - |
46 |
| - ./nflow-generator -t <ip> -p <port> [ -f | --false-index ] |
47 |
| - |
48 |
| -### Run a Test Collection |
49 |
| - |
50 |
| -You can run a simple test collection using nfcapd from the nfdump package with the following. |
51 |
| - |
52 |
| -- Start a netflow collector |
53 |
| - |
54 |
| -``` |
55 |
| -sudo apt-get install nfdump |
56 |
| -mkdir /tmp/nfcap-test |
57 |
| -nfcapd -E -p 9001 -l /tmp/nfcap-test |
| 37 | +```bash |
| 38 | +go build # one time |
| 39 | +./manflow -i gw1 |
58 | 40 | ```
|
59 | 41 |
|
60 |
| -In a seperate console, run the netflow-generator pointing at an IP on the host the collector is running on (in this case the VM has an IP of 192.168.1.113). |
61 |
| - |
62 |
| -``` |
63 |
| -sudo docker run -it --rm networkstatic/nflow-generator -t 192.168.1.113 -p 9001 |
64 |
| -``` |
65 |
| - |
66 |
| -- You should start seeing records displayed to the output of the screen running nfcapd like the following. |
67 |
| - |
68 |
| -``` |
69 |
| -$> nfcapd -E -p 9001 -l /tmp/nfcap-test |
70 |
| -Add extension: 2 byte input/output interface index |
71 |
| -Add extension: 4 byte input/output interface index |
72 |
| -Add extension: 2 byte src/dst AS number |
73 |
| -Add extension: 4 byte src/dst AS number |
74 |
| -Bound to IPv4 host/IP: any, Port: 9001 |
75 |
| -Startup. |
76 |
| -Init IPFIX: Max number of IPFIX tags: 62 |
77 |
| -
|
78 |
| -Flow Record: |
79 |
| - Flags = 0x00 FLOW, Unsampled |
80 |
| - export sysid = 1 |
81 |
| - size = 56 |
82 |
| - first = 1552592037 [2019-03-14 15:33:57] |
83 |
| - last = 1552592038 [2019-03-14 15:33:58] |
84 |
| - msec_first = 973 |
85 |
| - msec_last = 414 |
86 |
| - src addr = 112.10.20.10 |
87 |
| - dst addr = 172.30.190.10 |
88 |
| - src port = 40 |
89 |
| - dst port = 80 |
90 |
| - fwd status = 0 |
91 |
| - tcp flags = 0x00 ...... |
92 |
| - proto = 6 TCP |
93 |
| - (src)tos = 0 |
94 |
| - (in)packets = 792 |
95 |
| - (in)bytes = 23 |
96 |
| - input = 0 |
97 |
| - output = 0 |
98 |
| - src as = 48730 |
99 |
| - dst as = 15401 |
100 |
| -
|
101 |
| -
|
102 |
| -Flow Record: |
103 |
| - Flags = 0x00 FLOW, Unsampled |
104 |
| - export sysid = 1 |
105 |
| - size = 56 |
106 |
| - first = 1552592038 [2019-03-14 15:33:58] |
107 |
| - last = 1552592038 [2019-03-14 15:33:58] |
108 |
| - msec_first = 229 |
109 |
| - msec_last = 379 |
110 |
| - src addr = 192.168.20.10 |
111 |
| - dst addr = 202.12.190.10 |
112 |
| - src port = 40 |
113 |
| - dst port = 443 |
114 |
| - fwd status = 0 |
115 |
| - tcp flags = 0x00 ...... |
116 |
| - proto = 6 TCP |
117 |
| - (src)tos = 0 |
118 |
| - (in)packets = 599 |
119 |
| - (in)bytes = 602 |
120 |
| - input = 0 |
121 |
| - output = 0 |
122 |
| - src as = 1115 |
123 |
| - dst as = 50617 |
124 |
| -
|
125 |
| -``` |
126 |
| - |
127 |
| -### Notes |
128 |
| - |
129 |
| -The original mock netflow generator placed random values in several fields which confused |
130 |
| -certain netflow collectors that complained about inaccurate time stamps, |
131 |
| -and were confused by the random values sent in the input and output interface fields. |
132 |
| - |
133 |
| -Changes: |
134 |
| - |
135 |
| -* Sets the `SysUptime`, `unix_secs`, and `unix_nsecs` fields of the Netflow datagrams to sensible (UTC) values |
136 |
| -* Generates a unique `flow_sequence` value for each netflow datagram |
137 |
| -* Creates reasonable start/stop times for flows, so the First is set to (now-X) and Last to (now-Y), where X & Y are random times, and X > Y. |
138 |
| -* If the --false-index (-f) flag is set on the command line, |
139 |
| -use this algorithm to set the interface indexes to 1 or 2: |
140 |
| -If the source address > dest address, input interface is set to 1, and set to 2 otherwise, |
141 |
| -and the output interface is set to the opposite value. |
142 |
| -If the -f is missing, both snmp interface indexes will be set to 0. [Default] |
| 42 | +Command-line arguments: |
143 | 43 |
|
144 |
| -To learn more about Netflow version 5 datagram formats, see the [Cisco Netflow documentation](http://www.cisco.com/c/en/us/td/docs/net_mgmt/netflow_collection_engine/3-6/user/guide/format.html) |
| 44 | +- `-i` - host name of one of the hosts in `flowConfig.json` file |
| 45 | +- `-l` - disable flow-level logging |
0 commit comments