- NetBSD Manual Pages
NPFD(8) NetBSD System Manager's Manual NPFD(8)
Powered by man-cgi (2021-03-02).
Maintained for NetBSD
by Kimmo Suominen.
Based on man-cgi by Panagiotis Christias.
npfd -- packet filter logging and state synchronization daemon
npfd [-D] [-d delay] [-f filename] [-i interface] [-p pidfile]
[-s snaplen] [expression]
npfd is a background daemon which writes to a file in pcap(3) format
logged packets read from an npflog interface. The npflog interface is
used by npf(7) to log packets as defined in npf.conf(5). The generated
pcap(3) files can then be analysed using tools such as tcpdump(8).
npfd closes and then re-opens the log file when it receives SIGHUP, per-
mitting newsyslog(8) to rotate logfiles automatically. SIGALRM causes
npfd to flush the current logfile buffers to the disk, thus making the
most recent logs available. The buffers are also flushed every delay
If the log file contains data after a restart or a SIGHUP, new logs are
appended to the existing file. If the existing log file was created with
a different snaplen, npfd temporarily uses the old snaplen to keep the
log file consistent.
npfd tries to preserve the integrity of the log file against I/O errors.
Furthermore, integrity of an existing log file is verified before append-
ing. If there is an invalid log file or an I/O error, the log file is
moved out of the way and a new one is created. If a new file cannot be
created, logging is suspended until a SIGHUP or a SIGALRM is received.
If SIGINFO is received, then npfd logs capture statistics to syslogd(8).
The options are as follows:
-D Debugging mode. npfd does not disassociate from the controlling
Time in seconds to delay between automatic flushes of the file.
This may be specified with a value between 5 and 3600 seconds.
If not specified, the default is 60 seconds.
Log output filename. Default is /var/log/npflog0.pcap.
Specifies the npflog interface to use. By default, npfd will use
Writes a file containing the process ID of the program. The file
name has the form /var/run/npfd.pid. If the option is not given,
pidfile defaults to npfd.
Analyze at most the first snaplen bytes of data from each packet
rather than the default of 116. The default of 116 is adequate
for IP, ICMP, TCP, and UDP headers but may truncate protocol
information for other protocols. Other file parsers may desire a
Selects which packets will be dumped, using the regular language
/var/run/npfd.pid Process ID of the currently running npfd.
/var/log/npflog0.pcap Default log file.
Log specific tcp packets to a different log file with a large snaplen
(useful with a log-all rule to dump complete sessions):
# npfd -s 1600 -f suspicious.log port 80 and host evilhost
Log from another npflog interface, excluding specific packets:
# npfd -i npflog3 -f network3.log "not (tcp and port 23)"
Display binary logs:
# tcpdump -n -e -ttt -r /var/log/npflog0.pcap
Display the logs in real time (this does not interfere with the operation
# tcpdump -n -e -ttt -i npflog0
Tcpdump has been extended to be able to filter on the OpenBSD pfloghdr
structure defined in sys/net/npf/if_npflog.h. Tcpdump can restrict the
output to packets logged on a specified interface, a rule number, a rea-
son, a direction, an IP family or an action.
ip Address family equals IPv4.
ip6 Address family equals IPv6.
ifname kue0 Interface name equals "kue0".
on kue0 Interface name equals "kue0".
ruleset rules Ruleset name equals "rules".
rulenum 10 Rule number equals 10.
reason match Reason equals match.
action pass Action equals pass. Also accepts "block".
inbound The direction was inbound.
outbound The direction was outbound.
Display the logs in real time of inbound packets that were blocked on the
# tcpdump -n -e -ttt -i npflog0 inbound and action block and on wi0
Each npf(7) rule is marked with an id number, shown using:
# npfctl show
block final all apply "log" # id="45"
This id is the rule id shown by tcpdump:
# tcpdump -enr /var/log/npflog0.pcap
11:26:02.288199 rule 45.rules.0/0(match): block in on sk0: \
220.127.116.11.46063 > 18.104.22.168.23231: Flags [S], seq 1, win 8192, \
options [mss 1440], length 0
pcap(3), npf.conf(5), npf(7), newsyslog(8), npfctl(8), tcpdump(8)
The npfd command appeared in NetBSD 8.0.
This manual page was written by Can Erkin Acar <email@example.com>.
Offline analysis of captured data is advised to alleviate issues with
malicious data intended to exploit bugs in the packet parsing code of
NetBSD 9.99 August 7, 2018 NetBSD 9.99