xref: /freebsd/contrib/pf/pflogd/pflogd.8 (revision 2357939bc239bd5334a169b62313806178dd8f30)
1.\"	$OpenBSD: pflogd.8,v 1.22 2003/06/03 13:16:08 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 D
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.Va SIGHUP ,
61permitting
62.Xr newsyslog 8
63to rotate logfiles automatically.
64.Va 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.Va 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
80The options are as follows:
81.Bl -tag -width Ds
82.It Fl d Ar delay
83Time in seconds to delay between automatic flushes of the file.
84This may be specified with a value between 5 and 3600 seconds.
85If not specified, the default is 60 seconds.
86.It Fl D
87Debugging mode.
88.Nm
89does not disassociate from the controlling terminal.
90.It Fl f Ar filename
91Log output filename.
92Default is
93.Pa /var/log/pflog .
94.It Fl s Ar snaplen
95Analyze at most the first
96.Ar snaplen
97bytes of data from each packet rather than the default of 96.
98The default of 96 is adequate for IP, ICMP, TCP, and UDP headers but may
99truncate protocol information for other protocols.
100Other file parsers may desire a higher snaplen.
101.It Ar expression
102Selects which packets will be dumped, using the regular language of
103.Xr tcpdump 8 .
104.El
105.Sh FILES
106.Bl -tag -width /var/run/pflogd.pid -compact
107.It Pa /var/run/pflogd.pid
108Process ID of the currently running
109.Nm pflogd .
110.It Pa /var/log/pflog
111Default log file.
112.El
113.Sh EXAMPLES
114Log specific tcp packets to a different log file with a large snaplen
115(useful with a log-all rule to dump complete sessions)
116.Bd -literal -offset indent
117# pflogd -s 1600 -f suspicious.log port 80 and host evilhost
118.Ed
119.Pp
120Display binary logs:
121.Bd -literal -offset indent
122# tcpdump -n -e -ttt -r /var/log/pflog
123.Ed
124.Pp
125Display the logs in real time (this does not interfere with the
126operation of pflogd):
127.Bd -literal -offset indent
128# tcpdump -n -e -ttt -i pflog0
129.Ed
130.Pp
131Tcpdump has been extended to be able to filter on the pfloghdr
132structure defined in
133.Aq Ar net/if_pflog.h .
134Tcpdump can restrict the output
135to packets logged on a specified interface, a rule number, a reason,
136a direction, an ip family or an action.
137.Pp
138.Bl -tag -width "reason match " -compact
139.It ip
140Address family equals IPv4.
141.It ip6
142Address family equals IPv6.
143.It ifname kue0
144Interface name equals "kue0"
145.It on kue0
146Interface name equals "kue0"
147.It rulenum 10
148Rule number equals 10.
149.It reason match
150Reason equals match.
151Also accepts "bad-offset", "fragment", "short", "normalize" and "memory".
152.It action pass
153Action equals pass.
154Also accepts "block".
155.It inbound
156The direction was inbound.
157.It outbound
158The direction was outbound.
159.El
160.Pp
161Display the logs in real time of inbound packets that were blocked on
162the wi0 interface:
163.Bd -literal -offset indent
164# tcpdump -n -e -ttt -i pflog0 inbound and action block and on wi0
165.Ed
166.Sh SEE ALSO
167.Xr pcap 3 ,
168.Xr pf 4 ,
169.Xr pflog 4 ,
170.Xr pf.conf 5 ,
171.Xr newsyslog 8 ,
172.Xr tcpdump 8
173.Sh HISTORY
174The
175.Nm
176command appeared in
177.Ox 3.0 .
178.Sh AUTHORS
179Can Erkin Acar
180