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.201107110845 contains the data from July 11th 2011 08:45 onward.
17
18       Netflow  version  v1,  v5,  v7  and v9 and IPFIX are transparently sup‐
19       ported.
20
21       Extensions: nfcapd supports a large number of  v9  tags.  In  order  to
22       optimise  disk space and performance, v9 tags are grouped into a number
23       of extensions which may or may not be stored into the data file. There‐
24       fore the v9 templates configured on the exporter may be tuned according
25       the collector. Only those tags common to both are stored into the  data
26       files.
27
28       Sampling:  By  default, the sampling rate is set to 1 (unsampled) or to
29       any given value specified by the -s cmd line option. If sampling infor‐
30       mation is found in the netflow stream, it overwrites the default value.
31       Sampling is automatically recognised when announced in v9  option  tem‐
32       plates (tags #34, #35 or #48, #49, #50 ) or in the unofficial v5 header
33       hack.  Note: Not all platforms (or IOS/JunOS versions) support  export‐
34       ing  sampling  information in netflow data, even if sampling is config‐
35       ured. The number of bytes/packets in each netflow record  is  automati‐
36       cally  multiplied  by  the sampling rate.  The total number of flows is
37       not changed as this is not accurate enough. (Small flows  versus  large
38       flows)  If the default sampling rate given by -s is negative, this will
39       hard overwrite any device specific announced sampling rates.
40
41       NSEL/ASA  Support:  nfcapd  can  be  compiled  with  NSEL/ASA   support
42       included. See notes on NSEL/ASA
43
44       NEL  (NAT Event logging): nfcapd can be compiled with CISCO NEL support
45       included.  See notes on NEL.
46

OPTIONS

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

RETURN VALUE

253       Returns 0 on success, or 255 if initialization failed.
254

LOGGING

256       nfcapd logs to syslog with SYSLOG_FACILITY LOG_DAEMON For normal opera‐
257       tion level 'warning' should be fine.  More information is  reported  at
258       level 'info' and 'debug'.
259
260       A  small  statistic  about  the  collected flows, as well as errors are
261       reported at the end of every interval to syslog with level 'info'.
262

EXAMPLES

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

NOTES

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

SEE ALSO

369       nfdump(1), nfprofile(1), nfreplay(1)
370

BUGS

372       No software without bugs! Please report any bugs back to me.
373
374
375
376                                  2009-09-09                         nfcapd(1)
Impressum