xref: /netbsd-src/dist/pf/sbin/pflogd/pflogd.8 (revision abb0f93cd77b67f080613360c65701f85e5f5cfe)
1.\"	$NetBSD: pflogd.8,v 1.6 2009/03/22 14:29:35 perry Exp $
2.\"	$OpenBSD: pflogd.8,v 1.35 2007/05/31 19:19:47 jmc Exp $
3.\"
4.\" Copyright (c) 2001 Can Erkin Acar.  All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\" 3. The name of the author may not be used to endorse or promote products
15.\"    derived from this software without specific prior written permission.
16.\"
17.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27.\"
28.Dd May 31, 2007
29.Dt PFLOGD 8
30.Os
31.Sh NAME
32.Nm pflogd
33.Nd packet filter logging daemon
34.Sh SYNOPSIS
35.Nm pflogd
36.Bk -words
37.Op Fl Dx
38.Op Fl d Ar delay
39.Op Fl f Ar filename
40.Op Fl i Ar interface
41.Op Fl p Ar pidfile
42.Op Fl s Ar snaplen
43.Op Ar expression
44.Ek
45.Sh DESCRIPTION
46.Nm
47is a background daemon which reads packets logged by
48.Xr pf 4
49to a
50.Xr pflog 4
51interface, normally
52.Pa pflog0 ,
53and writes the packets to a logfile (normally
54.Pa /var/log/pflog )
55in
56.Xr tcpdump 8
57binary format.
58These logs can be reviewed later using the
59.Fl r
60option of
61.Xr tcpdump 8 ,
62hopefully offline in case there are bugs in the packet parsing code of
63.Xr tcpdump 8 .
64.Pp
65.Nm
66closes and then re-opens the log file when it receives
67.Dv SIGHUP ,
68permitting
69.Xr newsyslog 8
70to rotate logfiles automatically.
71.Dv SIGALRM
72causes
73.Nm
74to flush the current logfile buffers to the disk, thus making the most
75recent logs available.
76The buffers are also flushed every
77.Ar delay
78seconds.
79.Pp
80If the log file contains data after a restart or a
81.Dv SIGHUP ,
82new logs are appended to the existing file.
83If the existing log file was created with a different snaplen,
84.Nm
85temporarily uses the old snaplen to keep the log file consistent.
86.Pp
87.Nm
88tries to preserve the integrity of the log file against I/O errors.
89Furthermore, integrity of an existing log file is verified before
90appending.
91If there is an invalid log file or an I/O error, the log file is moved
92out of the way and a new one is created.
93If a new file cannot be created, logging is suspended until a
94.Dv SIGHUP
95or a
96.Dv SIGALRM
97is received.
98.Pp
99The options are as follows:
100.Bl -tag -width Ds
101.It Fl D
102Debugging mode.
103.Nm
104does not disassociate from the controlling terminal.
105.It Fl d Ar delay
106Time in seconds to delay between automatic flushes of the file.
107This may be specified with a value between 5 and 3600 seconds.
108If not specified, the default is 60 seconds.
109.It Fl f Ar filename
110Log output filename.
111Default is
112.Pa /var/log/pflog .
113.It Fl i Ar interface
114Specifies the
115.Xr pflog 4
116interface to use.
117By default,
118.Nm
119will use
120.Ar pflog0 .
121.It Fl p Ar pidfile
122Writes a file containing the process ID of the program.
123The file name has the form
124.Pa /var/run/pidname.pid .
125If the option is not given,
126.Ar pidfile
127defaults to
128.Pa pflogd .
129.It Fl s Ar snaplen
130Analyze at most the first
131.Ar snaplen
132bytes of data from each packet rather than the default of 116.
133The default of 116 is adequate for IP, ICMP, TCP, and UDP headers but may
134truncate protocol information for other protocols.
135Other file parsers may desire a higher snaplen.
136.It Fl x
137Check the integrity of an existing log file, and return.
138.It Ar expression
139Selects which packets will be dumped, using the regular language of
140.Xr tcpdump 8 .
141.El
142.Sh FILES
143.Bl -tag -width /var/run/pflogd.pid -compact
144.It Pa /var/run/pflogd.pid
145Process ID of the currently running
146.Nm .
147.It Pa /var/log/pflog
148Default log file.
149.El
150.Sh EXAMPLES
151Log specific tcp packets to a different log file with a large snaplen
152(useful with a log-all rule to dump complete sessions):
153.Bd -literal -offset indent
154# pflogd -s 1600 -f suspicious.log port 80 and host evilhost
155.Ed
156.Pp
157Log from another
158.Xr pflog 4
159interface, excluding specific packets:
160.Bd -literal -offset indent
161# pflogd -i pflog3 -f network3.log "not (tcp and port 23)"
162.Ed
163.Pp
164Display binary logs:
165.Bd -literal -offset indent
166# tcpdump -n -e -ttt -r /var/log/pflog
167.Ed
168.Pp
169Display the logs in real time (this does not interfere with the
170operation of
171.Nm ) :
172.Bd -literal -offset indent
173# tcpdump -n -e -ttt -i pflog0
174.Ed
175.Pp
176Tcpdump has been extended to be able to filter on the pfloghdr
177structure defined in
178.Aq Ar net/if_pflog.h .
179Tcpdump can restrict the output
180to packets logged on a specified interface, a rule number, a reason,
181a direction, an IP family or an action.
182.Pp
183.Bl -tag -width "ruleset authpf " -compact
184.It ip
185Address family equals IPv4.
186.It ip6
187Address family equals IPv6.
188.It ifname kue0
189Interface name equals "kue0".
190.It on kue0
191Interface name equals "kue0".
192.It ruleset authpf
193Ruleset name equals "authpf".
194.It rulenum 10
195Rule number equals 10.
196.It reason match
197Reason equals match.
198Also accepts "bad-offset", "fragment", "bad-timestamp", "short",
199"normalize", "memory", "congestion", "ip-option", "proto-cksum",
200"state-mismatch", "state-insert", "state-limit", "src-limit",
201and "synproxy".
202.It action pass
203Action equals pass.
204Also accepts "block".
205.It inbound
206The direction was inbound.
207.It outbound
208The direction was outbound.
209.El
210.Pp
211Display the logs in real time of inbound packets that were blocked on
212the wi0 interface:
213.Bd -literal -offset indent
214# tcpdump -n -e -ttt -i pflog0 inbound and action block and on wi0
215.Ed
216.Sh SEE ALSO
217.Xr pcap 3 ,
218.Xr pf 4 ,
219.Xr pflog 4 ,
220.Xr pf.conf 5 ,
221.Xr newsyslog 8 ,
222.Xr tcpdump 8
223.Sh HISTORY
224The
225.Nm
226command appeared in
227.Ox 3.0 .
228.Sh AUTHORS
229.Nm
230was written by
231.An Can Erkin Acar Aq canacar@openbsd.org .
232