xref: /freebsd/contrib/pf/pflogd/pflogd.8 (revision f0adf7f5cdd241db2f2c817683191a6ef64a4e95)
1.\"	$OpenBSD: pflogd.8,v 1.24 2004/01/16 10:45:49 jmc 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.Dd July 9, 2001
28.Dt PFLOGD 8
29.Os
30.Sh NAME
31.Nm pflogd
32.Nd packet filter logging daemon
33.Sh SYNOPSIS
34.Nm pflogd
35.Op Fl Dx
36.Op Fl d Ar delay
37.Op Fl f Ar filename
38.Op Fl s Ar snaplen
39.Op Ar expression
40.Sh DESCRIPTION
41.Nm
42is a background daemon which reads packets logged by
43.Xr pf 4
44to the packet logging interface
45.Pa pflog0
46and writes the packets to a logfile (normally
47.Pa /var/log/pflog )
48in
49.Xr tcpdump 8
50binary format.
51These logs can be reviewed later using the
52.Fl r
53option of
54.Xr tcpdump 8 ,
55hopefully offline in case there are bugs in the packet parsing code of
56.Xr tcpdump 8 .
57.Pp
58.Nm
59closes and then re-opens the log file when it receives
60.Dv SIGHUP ,
61permitting
62.Xr newsyslog 8
63to rotate logfiles automatically.
64.Dv SIGALRM
65causes
66.Nm
67to flush the current logfile buffers to the disk, thus making the most
68recent logs available.
69The buffers are also flushed every
70.Ar delay
71seconds.
72.Pp
73If the log file contains data after a restart or a
74.Dv SIGHUP ,
75new logs are appended to the existing file.
76If the existing log file was created with a different snaplen,
77.Nm
78temporarily uses the old snaplen to keep the log file consistent.
79.Pp
80.Nm
81tries to preserve the integrity of the log file against I/O errors.
82Furthermore, integrity of an existing log file is verified before
83appending.
84If there is an invalid log file or an I/O error, logging is suspended until a
85.Dv SIGHUP
86or a
87.Dv SIGALRM
88is received.
89.Pp
90The options are as follows:
91.Bl -tag -width Ds
92.It Fl D
93Debugging mode.
94.Nm
95does not disassociate from the controlling terminal.
96.It Fl d Ar delay
97Time in seconds to delay between automatic flushes of the file.
98This may be specified with a value between 5 and 3600 seconds.
99If not specified, the default is 60 seconds.
100.It Fl f Ar filename
101Log output filename.
102Default is
103.Pa /var/log/pflog .
104.It Fl s Ar snaplen
105Analyze at most the first
106.Ar snaplen
107bytes of data from each packet rather than the default of 96.
108The default of 96 is adequate for IP, ICMP, TCP, and UDP headers but may
109truncate protocol information for other protocols.
110Other file parsers may desire a higher snaplen.
111.It Fl x
112Check the integrity of an existing log file, and return.
113.It Ar expression
114Selects which packets will be dumped, using the regular language of
115.Xr tcpdump 8 .
116.El
117.Sh FILES
118.Bl -tag -width /var/run/pflogd.pid -compact
119.It Pa /var/run/pflogd.pid
120Process ID of the currently running
121.Nm .
122.It Pa /var/log/pflog
123Default log file.
124.El
125.Sh EXAMPLES
126Log specific tcp packets to a different log file with a large snaplen
127(useful with a log-all rule to dump complete sessions):
128.Bd -literal -offset indent
129# pflogd -s 1600 -f suspicious.log port 80 and host evilhost
130.Ed
131.Pp
132Display binary logs:
133.Bd -literal -offset indent
134# tcpdump -n -e -ttt -r /var/log/pflog
135.Ed
136.Pp
137Display the logs in real time (this does not interfere with the
138operation of
139.Nm ) :
140.Bd -literal -offset indent
141# tcpdump -n -e -ttt -i pflog0
142.Ed
143.Pp
144Tcpdump has been extended to be able to filter on the pfloghdr
145structure defined in
146.Aq Ar net/if_pflog.h .
147Tcpdump can restrict the output
148to packets logged on a specified interface, a rule number, a reason,
149a direction, an IP family or an action.
150.Pp
151.Bl -tag -width "reason match " -compact
152.It ip
153Address family equals IPv4.
154.It ip6
155Address family equals IPv6.
156.It ifname kue0
157Interface name equals "kue0".
158.It on kue0
159Interface name equals "kue0".
160.It rulenum 10
161Rule number equals 10.
162.It reason match
163Reason equals match.
164Also accepts "bad-offset", "fragment", "short", "normalize" and "memory".
165.It action pass
166Action equals pass.
167Also accepts "block".
168.It inbound
169The direction was inbound.
170.It outbound
171The direction was outbound.
172.El
173.Pp
174Display the logs in real time of inbound packets that were blocked on
175the wi0 interface:
176.Bd -literal -offset indent
177# tcpdump -n -e -ttt -i pflog0 inbound and action block and on wi0
178.Ed
179.Sh SEE ALSO
180.Xr pcap 3 ,
181.Xr pf 4 ,
182.Xr pflog 4 ,
183.Xr pf.conf 5 ,
184.Xr newsyslog 8 ,
185.Xr tcpdump 8
186.Sh HISTORY
187The
188.Nm
189command appeared in
190.Ox 3.0 .
191.Sh AUTHORS
192Can Erkin Acar
193