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