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