xref: /freebsd/contrib/pf/pflogd/pflogd.8 (revision b740c88bfb6453416926271c089262e7164dace3)
1.\"	$OpenBSD: pflogd.8,v 1.37 2008/10/22 08:16:49 henning Exp $
2.\"
3.\" Copyright (c) 2001 Can Erkin Acar.  All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\" 3. The name of the author may not be used to endorse or promote products
14.\"    derived from this software without specific prior written permission.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26.\"
27.\" $FreeBSD$
28.\"
29.Dd October 22 2008
30.Dt PFLOGD 8
31.Os
32.Sh NAME
33.Nm pflogd
34.Nd packet filter logging daemon
35.Sh SYNOPSIS
36.Nm pflogd
37.Bk -words
38.Op Fl Dx
39.Op Fl d Ar delay
40.Op Fl f Ar filename
41.Op Fl i Ar interface
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 1
57binary format.
58These logs can be reviewed later using the
59.Fl r
60option of
61.Xr tcpdump 1 ,
62hopefully offline in case there are bugs in the packet parsing code of
63.Xr tcpdump 1 .
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
99.Nm
100will also log the pcap statistics for the
101.Xr pflog 4
102interface to syslog when a
103.Dv SIGUSR1
104is received.
105.Pp
106The options are as follows:
107.Bl -tag -width Ds
108.It Fl D
109Debugging mode.
110.Nm
111does not disassociate from the controlling terminal.
112.It Fl d Ar delay
113Time in seconds to delay between automatic flushes of the file.
114This may be specified with a value between 5 and 3600 seconds.
115If not specified, the default is 60 seconds.
116.It Fl f Ar filename
117Log output filename.
118Default is
119.Pa /var/log/pflog .
120.It Fl i Ar interface
121Specifies the
122.Xr pflog 4
123interface to use.
124By default,
125.Nm
126will use
127.Ar pflog0 .
128Writes a file containing the process ID of the program to
129.Pa /var/run .
130The file name has the form
131The default is
132.Ar pflogd .
133.It Fl s Ar snaplen
134Analyze at most the first
135.Ar snaplen
136bytes of data from each packet rather than the default of 116.
137The default of 116 is adequate for IP, ICMP, TCP, and UDP headers but may
138truncate protocol information for other protocols.
139Other file parsers may desire a higher snaplen.
140.It Fl x
141Check the integrity of an existing log file, and return.
142.It Ar expression
143Selects which packets will be dumped, using the regular language of
144.Xr tcpdump 1 .
145.El
146.Sh FILES
147.Bl -tag -width /var/run/pflogd.pid -compact
148.It Pa /var/run/pflogd.pid
149Process ID of the currently running
150.Nm .
151.It Pa /var/log/pflog
152Default log file.
153.El
154.Sh EXAMPLES
155Log specific tcp packets to a different log file with a large snaplen
156(useful with a log-all rule to dump complete sessions):
157.Bd -literal -offset indent
158# pflogd -s 1600 -f suspicious.log port 80 and host evilhost
159.Ed
160.Pp
161Log from another
162.Xr pflog 4
163interface, excluding specific packets:
164.Bd -literal -offset indent
165# pflogd -i pflog3 -f network3.log "not (tcp and port 23)"
166.Ed
167.Pp
168Display binary logs:
169.Bd -literal -offset indent
170# tcpdump -n -e -ttt -r /var/log/pflog
171.Ed
172.Pp
173Display the logs in real time (this does not interfere with the
174operation of
175.Nm ) :
176.Bd -literal -offset indent
177# tcpdump -n -e -ttt -i pflog0
178.Ed
179.Pp
180Tcpdump has been extended to be able to filter on the pfloghdr
181structure defined in
182.Aq Ar net/if_pflog.h .
183Tcpdump can restrict the output
184to packets logged on a specified interface, a rule number, a reason,
185a direction, an IP family or an action.
186.Pp
187.Bl -tag -width "ruleset authpf " -compact
188.It ip
189Address family equals IPv4.
190.It ip6
191Address family equals IPv6.
192.It ifname kue0
193Interface name equals "kue0".
194.It on kue0
195Interface name equals "kue0".
196.It ruleset authpf
197Ruleset name equals "authpf".
198.It rulenum 10
199Rule number equals 10.
200.It reason match
201Reason equals match.
202Also accepts "bad-offset", "fragment", "bad-timestamp", "short",
203"normalize", "memory", "congestion", "ip-option", "proto-cksum",
204"state-mismatch", "state-insert", "state-limit", "src-limit",
205and "synproxy".
206.It action pass
207Action equals pass.
208Also accepts "block".
209.It inbound
210The direction was inbound.
211.It outbound
212The direction was outbound.
213.El
214.Pp
215Display the logs in real time of inbound packets that were blocked on
216the wi0 interface:
217.Bd -literal -offset indent
218# tcpdump -n -e -ttt -i pflog0 inbound and action block and on wi0
219.Ed
220.Sh SEE ALSO
221.Xr pcap 3 ,
222.Xr pf 4 ,
223.Xr pflog 4 ,
224.Xr pf.conf 5 ,
225.Xr newsyslog 8 ,
226.Xr tcpdump 1
227.Sh HISTORY
228The
229.Nm
230command appeared in
231.Ox 3.0 .
232.Sh AUTHORS
233.Nm
234was written by
235.An Can Erkin Acar Aq canacar@openbsd.org .
236