1nfcapd(1)                                                            nfcapd(1)
2
3
4

NAME

6       nfcapd - netflow capture daemon
7

SYNOPSIS

9       nfcapd [options]
10

DESCRIPTION

12       nfcapd is the netflow capture daemon of the nfdump tools. It reads net‐
13       flow data from the network and stores it into files. The output file is
14       automatically  rotated  and renamed every n minutes - typically 5 min -
15       according   the   timestamp   YYYYMMddhhmm   of   the   interval   e.g.
16       nfcapd.201907110845 contains the data from July 11th 2019 08:45 onward.
17       If the time interval is smaller then 60s, the naming extends to seconds
18       e.g. nfcapd.20190711084510.
19
20
21       Netflow  version  v1,  v5,  v7  and v9 and IPFIX are transparently sup‐
22       ported.
23
24       Extensions: nfcapd supports a large number of  v9  tags.  In  order  to
25       optimise  disk space and performance, v9 tags are grouped into a number
26       of extensions which may or may not be stored into the data file. There‐
27       fore the v9 templates configured on the exporter may be tuned according
28       the collector. Only those tags common to both are stored into the  data
29       files.
30
31       Sampling:  By  default, the sampling rate is set to 1 (unsampled) or to
32       any given value specified by the -s cmd line option. If sampling infor‐
33       mation is found in the netflow stream, it overwrites the default value.
34       Sampling is automatically recognised when announced in v9  option  tem‐
35       plates (tags #34, #35 or #48, #49, #50 ) or in the unofficial v5 header
36       hack.  Note: Not all platforms (or IOS/JunOS versions) support  export‐
37       ing  sampling  information in netflow data, even if sampling is config‐
38       ured. The number of bytes/packets in each netflow record  is  automati‐
39       cally  multiplied  by  the sampling rate.  The total number of flows is
40       not changed as this is not accurate enough. (Small flows  versus  large
41       flows)  If the default sampling rate given by -s is negative, this will
42       hard overwrite any device specific announced sampling rates.
43
44       NSEL/ASA  Support:  nfcapd  can  be  compiled  with  NSEL/ASA   support
45       included. See notes on NSEL/ASA
46
47       NEL  (NAT Event logging): nfcapd can be compiled with CISCO NEL support
48       included.  See notes on NEL.
49

OPTIONS

51       -p portnum
52          Specifies the port number to listen. Default port is 9995
53
54       -b bindhost
55          Specifies the hostname/IPv4/IPv6 address to bind for listening. This
56          can  be  an  IP  address  or  a hostname, resolving to an IP address
57          attached to an interface.  Defaults to any available IPv4 interface,
58          if not specified.
59
60       -4 Forces nfcapd to listen on IPv4 addresses only. Can be used together
61          with -b if a hostname has an IPv4 and IPv6 address record.
62
63       -6 Forces nfcapd to listen on IPv6 addresses only. Can be used together
64          with -b if a hostname has an IPv4 and IPv6 address record. Depending
65          on the socket implementation -6 also accepts IPv4 data.
66
67       -J MulticastGroup
68          Join the specified IPv4 or IPv6 multicast group for listening.
69
70       -R host[/port}
71          Enable packet repeater. Send all incoming packets  to  another  host
72          and port.  host is either a valid IPv4/IPv6 address, or a valid sym‐
73          bolic hostname, which resolves to a IPv6 or IPv4 address.  port  may
74          be  omitted  and  defaults  to  port  9995.  Note:  Due to IPv4/IPv6
75          accepted addresses the port separator is '/'. Up to 8  repeaters  my
76          be defined.
77
78       -I IdentString ( capital letter i )
79          Specifies  an ident string, which describes the source e.g. the name
80          of the router. This string is put into the stat record  to  identify
81          the source. Default is 'none'. This is for compatibility with nfdump
82          1.5.x and used to specify a single netflow source. See -n
83
84       -l base_directory ( letter ell )
85          Specifies the base directory to store the output files.   If  a  sub
86          hierarchy  is  specified with -S the final directory is concatenated
87          to base_directory/sub_hierarchy.  This  is  for  compatibility  with
88          nfdump 1.5.x and used to specify a single netflow source. See -n
89
90       -n <Ident,IP,base_directory>
91          Configures  a netflow source named Ident and identified by source IP
92          address IP.  The base directory for the flow  files  is  base_direc‐
93          tory. If a sub hierarchy is specified with -S the final directory is
94          concatenated  to  base_directory/sub_hierarchy.   Multiple   netflow
95          sources  can  be specified. All data is sent to the same port speci‐
96          fied by -p.  Note: You must not mix -n option with -I  and  -l.  Use
97          either syntax.
98
99       -N <file>
100          Specifies the file to read to add multiple netflow sources. The file
101          is expected to contain one netflow source per line based on the same
102          syntax than the -n option. Comments are not interpreted.  Ident col‐
103          lision are not handled if -N is specified multiple times.
104
105       -M <dynbase_directory>
106          Specifies the base directory to store the output files. In  contrast
107          to  -l -M allows to add dynamically new flow sources (exporters), as
108          they appear. All exporters send netflow data to the  same  port  and
109          IP.   For  each dynamically added source, a new directory is created
110          with the name of the IPv4/IPv6 address of the exporter. All '.'  and
111          ':"  in  IP  addresses are replaced be '-' e.g.  10.11.12.13 is con‐
112          verted to the directory name 10-11-12-13.  Note: Please make sure to
113          restrict at host level the potential range of IP addresses which are
114          allowed to connect to nfcapd. Otherwise you  risk  a  potential  DoS
115          attack on nfcapd, as nfcapd has no built in restrictions.
116
117       -f <pcap_file>
118          Read  netflow  packets from a give pcap_file instead of the network.
119          This requires nfcapd to be compiled with  the  pcap  option  and  is
120          intended for debugging only.
121
122       -s <rate>
123          Apply  default sampling rate rate to all netflow records, unless the
124          sampling rate is announced by the exporting device. In that case the
125          announced sampling rate is applied. If <rate> is negative, this will
126          hard overwrite any device specific announced sampling rates.
127
128       -S <num>
129          Allows to specify an additional directory sub hierarchy to store the
130          data  files.  The  default  is  0, no sub hierarchy, which means the
131          files go directly in the base directory  (-l).  The  base  directory
132          (-l) is concatenated with the specified sub hierarchy format to form
133          the final data directory.  The following hierarchies are defined:
134            0 default     no hierarchy levels
135            1 %Y/%m/%d    year/month/day
136            2 %Y/%m/%d/%H year/month/day/hour
137            3 %Y/%W/%u    year/week_of_year/day_of_week
138            4 %Y/%W/%u/%H year/week_of_year/day_of_week/hour
139            5 %Y/%j       year/day-of-year
140            6 %Y/%j/%H    year/day-of-year/hour
141            7 %Y-%m-%d    year-month-day
142            8 %Y-%m-%d/%H year-month-day/hour
143
144       -T <extension list>
145          Specifies the list of extensions, to be stored in the netflow  file.
146          Regardless  of  the  extension  list,  the following netflow data is
147          stored per record:  first,  last,  fwd  status,  tcp  flags,  proto,
148          (src)tos,  src  port, dst port, src ipaddr, dst ipaddr, in(packets),
149          in(bytes). In addition nfcapd recognises the extensions as described
150          below. Some are valid for v5/v7/v9, but most of them make only sense
151          for v9. Any specified extensions which do not  exist  in  the  input
152          netflow records are ignored.
153
154          Extensions:
155           v5/v7/v9/IPFIX extensions:
156            1 input/output interface SNMP numbers.
157            2 src/dst AS numbers.
158            3 src/dst mask, (dst)TOS, direction.
159            4 line Next hop IP addr line
160            5 line BGP next hop IP addr line
161            6 src/dst vlan id labels
162            7 counter output packets
163            8 counter output bytes
164            9 counter aggregated flows
165           10 in_src/out_dst MAC address
166           11 in_dst/out_src MAC address
167           12 MPLS labels 1-10
168           13 Exporting router IPv4/IPv6 address
169           14 Exporting router ID
170           15 BGP adjacent prev/next AS
171           16 time stamp flow received by the collector
172           NSEL/ASA/NAT extensions
173           26 NSEL     ASA event, xtended event, ICMP type/code
174           27 NSEL/NAT xlate ports
175           28 NSEL/NAT xlate IPv4/IPv6 addr
176           29 NSEL     ASA ACL ingress/egress acl ID
177           30 NSEL     ASA username
178           NEL/NAT extensions
179           31 NAT event, ingress egress vrfid
180           32 NAT Block port allocation - block start, end step and size
181           latency extension
182           64 nfpcapd/nprobe client/server/application latency"},
183
184           IMPORTANT:  By  default  only extension 1 and 2 are selected Exten‐
185           sions can be added/deleted by specifying a ','  separated  list  of
186           extension  ids. Each id may be prepended by an optional sign +/- to
187           add or remove a given id from the extension list.   Shortcuts:  The
188           string 'all' means all extensions. The strings
189            'nsel' and 'nel' enable all NSEL or NEL extensions respectively.
190
191           Examples:
192           -T all       Enables all possible extensions.
193           -T +3,+4     Adds extensions 3 and 4 to the defaults 1 and 2.
194           -T all,-8,-9 Set all extensions but 8 and 9
195           -T -1,4      Removes default extension 1 and adds extension 4
196           -T nsel      Enables all required ASA?NSEL extensions
197           -T nel       Enables all required nell extensions
198           Note:  Only  those  tags  in  common  with the exporting device and
199           enabled extensions at the collector side are stored into  the  data
200           files.  A  detailed list which v9 tags are mapped into which exten‐
201           sions is given in the section NOTES
202
203       -t interval
204          Specifies the time interval in seconds to rotate files. The  default
205          value is 300s ( 5min ). The smallest interval is 2s.
206
207       -w Align file rotation with next n minute ( specified by -t ) interval.
208          Example: If interval is 5 min, sync at 0,5,10... wall clock  minutes
209          Default: no alignment.
210
211       -x cmd
212          Run  command  cmd  at  the  end  of  every interval, when a new file
213          becomes available. The following command expansion is available:
214           %f   Replaced by the file name e.g nfcapd.200907110845 inluding any
215                sub hierarchy. ( 2009/07/11/nfcapd.200907110845 )
216           %d   Replaced by the directory where the file is located.
217           %t   Replaced by the time ISO format e.g. 200907110845.
218           %u   Replaced by the UNIX time format.
219           %i   Replaced ident string given by -I
220
221       -X Collect and embed extended statistics. Currently a port and bpp his‐
222          togram is embedded. Mostly experimental for now
223
224       -e Auto  expire files at every cycle. max lifetime and max filesize are
225          defined using nfexpire(1)
226
227       -P pidfile
228          Specify name of pidfile. Default is no pidfile.
229
230       -D Daemon mode: fork to background and detach  from  terminal.   Nfcapd
231          terminates on signal TERM, INT and HUP.
232
233       -u userid
234          Change  to the user userid as soon as possible. Only root is allowed
235          to use this option.
236
237       -g groupid
238          Change to the group groupid  as  soon  as  possible.  Only  root  is
239          allowed use this option.
240
241       -B bufflen
242          Specifies  the  socket input buffer length in bytes. For high volume
243          traffic ( near GB traffic ) it is recommended to set this  value  as
244          high  as  possible  ( typically > 100k ), otherwise you risk to lose
245          packets. The default is OS ( and kernel )  dependent.
246
247       -E Print netflow records in nfdump raw format to stdout. This option is
248          for debugging purpose only, to see how incoming netflow data is pro‐
249          cessed and stored.
250
251       -j Compress flows. Use bz2 compression in output file. Note: not recom‐
252          mended while collecting
253
254       -y Compress flows. Use LZ4 compression in output file.
255
256       -z Compress flows. Use fast LZO1X-1 compression in output file.
257
258       -V Print nfcapd version and exit.
259
260       -h Print help text to stdout with all options and exit.
261

RETURN VALUE

263       Returns 0 on success, or 255 if initialization failed.
264

LOGGING

266       nfcapd logs to syslog with SYSLOG_FACILITY LOG_DAEMON For normal opera‐
267       tion level 'warning' should be fine.  More information is  reported  at
268       level 'info' and 'debug'.
269
270       A  small  statistic  about  the  collected flows, as well as errors are
271       reported at the end of every interval to syslog with level 'info'.
272

EXAMPLES

274       All flows are sent to port 9995 from all exporters and  stored  into  a
275       single file. All known v9 tags are taken.
276              nfcapd -z -w -D -T all -l /netflow/spool/allflows -I any -S 2 -P
277              /var/run/nfcapd.allflows.pid
278
279       All flows from 2 different exporters are sent to port 8877  and  stored
280       in  separate directory trees. All known v9 tags are taken. Input buffer
281       size is set to 128000 bytes
282              nfcapd -z -w -D -T all  -p  8877  -n  upstream,192.168.1.1,/net‐
283              flow/spool/upstream -n peer,192.168.2.1,/netflow/spool/peer -S 2
284              -B 128000
285
286       Only accept from from a single exporter and only extension  3,4  and  5
287       are  accepted. Run a given command when files are rotated and automati‐
288       cally expire flows:
289              nfcapd   -w   -D   -T   3,4,5   -n    upstream,192.168.1.1,/net‐
290              flow/spool/upstream  -p 23456 -B 128000 -s 100 -x '/path/command
291              -r %d/%f'  -P /var/run/nfcapd/nfcapd.pid -e
292

NOTES

294       Multiple netflow sources:
295
296       Netflow data may be sent from different exporters to  a  single  nfcapd
297       process.   Use  the -n option to separate each netflow source to a dif‐
298       ferent data directory.  For compatibility with nfdump 1.5.x, old  style
299       -l/-I options are still valid.  In that case all flows from all sources
300       are stored in a single file. For high volume  netflow  streams,  it  is
301       still recommended to have a single nfcapd process per netflow source.
302
303       The  current v9 implementation of nfdump supports the following v9 ele‐
304       ments: fields:
305           v9 element          v9 ID     Extension
306           NF9_LAST_SWITCHED      21       default
307           NF9_FIRST_SWITCHED     22       default
308           NF9_IN_BYTES            1       default
309           NF9_IN_PACKETS          2       default
310           NF9_IN_PROTOCOL         4       default
311           NF9_SRC_TOS             5       default
312           NF9_TCP_FLAGS           6       default
313           NF9_FORWARDING_STATUS  89       default
314           NF9_IPV4_SRC_ADDR       8       default
315           NF9_IPV4_DST_ADDR      12       default
316           NF9_IPV6_SRC_ADDR      27       default
317           NF9_IPV6_DST_ADDR      28       default
318           NF9_L4_SRC_PORT         7       default
319           NF9_L4_DST_PORT        11       default
320           NF9_ICMP_TYPE          32       default
321           NF9_INPUT_SNMP         10             1
322           NF9_OUTPUT_SNMP        14             1
323           NF9_SRC_AS             16             2
324           NF9_DST_AS             17             2
325           NF9_DST_TOS            55             3
326           NF9_DIRECTION          61             3
327           NF9_SRC_MASK            9             3
328           NF9_DST_MASK           13             3
329           NF9_IPV6_SRC_MASK      29             3
330           NF9_IPV6_DST_MASK      30             3
331           NF9_V4_NEXT_HOP        15             4
332           NF9_V6_NEXT_HOP        62             4
333           NF9_BGP_V4_NEXT_HOP    18             5
334           NF9_BPG_V6_NEXT_HOP    63             5
335           NF9_SRC_VLAN           58             6
336           NF9_DST_VLAN           59             6
337           NF9_OUT_PKTS           24             7
338           NF9_OUT_BYTES          23             8
339           NF9_FLOWS_AGGR          3             9
340           NF9_IN_SRC_MAC         56            10
341           NF9_OUT_DST_MAC        57            10
342           NF9_IN_DST_MAC         80            11
343           NF9_OUT_SRC_MAC        81            11
344           NF9_MPLS_LABEL_1       70            12
345           NF9_MPLS_LABEL_2       71            12
346           NF9_MPLS_LABEL_3       72            12
347           NF9_MPLS_LABEL_4       73            12
348           NF9_MPLS_LABEL_5       74            12
349           NF9_MPLS_LABEL_6       75            12
350           NF9_MPLS_LABEL_7       76            12
351           NF9_MPLS_LABEL_8       77            12
352           NF9_MPLS_LABEL_9       78            12
353           NF9_MPLS_LABEL_10      79            12
354           NF9_SAMPLING_INTERVAL  34            Sampling
355           NF9_SAMPLING_ALGORITHM 35            Sampling
356           NF9_FLOW_SAMPLER_ID    48            Sampling
357           FLOW_SAMPLER_MODE      49            Sampling
358           NF9_FLOW_SAMPLER_RANDOM_INTERVAL 50  Sampling
359           IP addr of exporting router          13
360           NF9_ENGINE_TYPE        38            14
361           NF9_ENGINE_ID          39            14
362           NF9_BGP_ADJ_NEXT_AS   128            15
363           NF9_BGP_ADJ_PREV_AS   129            15
364           collector received timestamp         16
365       32 and 64 bit are supported for all counters. 32it AS numbers are  sup‐
366       ported.
367
368       IPFIX  support  is  experimental. Due to lack of implementation of sam‐
369       pling in many IPFIX exporters, sampling for IPFIX is not yet supported.
370
371       The format of the data files is netflow version independent.
372
373       Socket buffer: Setting the socket  buffer  size  is  system  dependent.
374       When  starting  up,  nfcapd  returns the number of bytes the buffer was
375       actually set. This is done by reading back the buffer size and may dif‐
376       fer from what you requested.
377

SEE ALSO

379       nfdump(1), nfprofile(1), nfreplay(1)
380

BUGS

382       No software without bugs! Please report any bugs back to me.
383
384
385
386                                  2009-09-09                         nfcapd(1)
Impressum