]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/pf/pflogd/pflogd.8
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.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 Writes a file containing the process ID of the program to
129 .Pa /var/run .
130 The file name has the form
131 The default is
132 .Ar pflogd .
133 .It Fl s Ar snaplen
134 Analyze at most the first
135 .Ar snaplen
136 bytes of data from each packet rather than the default of 116.
137 The default of 116 is adequate for IP, ICMP, TCP, and UDP headers but may
138 truncate protocol information for other protocols.
139 Other file parsers may desire a higher snaplen.
140 .It Fl x
141 Check the integrity of an existing log file, and return.
142 .It Ar expression
143 Selects 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
149 Process ID of the currently running
150 .Nm .
151 .It Pa /var/log/pflog
152 Default log file.
153 .El
154 .Sh EXAMPLES
155 Log 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
161 Log from another
162 .Xr pflog 4
163 interface, excluding specific packets:
164 .Bd -literal -offset indent
165 # pflogd -i pflog3 -f network3.log "not (tcp and port 23)"
166 .Ed
167 .Pp
168 Display binary logs:
169 .Bd -literal -offset indent
170 # tcpdump -n -e -ttt -r /var/log/pflog
171 .Ed
172 .Pp
173 Display the logs in real time (this does not interfere with the
174 operation of
175 .Nm ) :
176 .Bd -literal -offset indent
177 # tcpdump -n -e -ttt -i pflog0
178 .Ed
179 .Pp
180 Tcpdump has been extended to be able to filter on the pfloghdr
181 structure defined in
182 .Aq Ar net/if_pflog.h .
183 Tcpdump can restrict the output
184 to packets logged on a specified interface, a rule number, a reason,
185 a direction, an IP family or an action.
186 .Pp
187 .Bl -tag -width "ruleset authpf " -compact
188 .It ip
189 Address family equals IPv4.
190 .It ip6
191 Address family equals IPv6.
192 .It ifname kue0
193 Interface name equals "kue0".
194 .It on kue0
195 Interface name equals "kue0".
196 .It ruleset authpf
197 Ruleset name equals "authpf".
198 .It rulenum 10
199 Rule number equals 10.
200 .It reason match
201 Reason equals match.
202 Also accepts "bad-offset", "fragment", "bad-timestamp", "short",
203 "normalize", "memory", "congestion", "ip-option", "proto-cksum",
204 "state-mismatch", "state-insert", "state-limit", "src-limit",
205 and "synproxy".
206 .It action pass
207 Action equals pass.
208 Also accepts "block".
209 .It inbound
210 The direction was inbound.
211 .It outbound
212 The direction was outbound.
213 .El
214 .Pp
215 Display the logs in real time of inbound packets that were blocked on
216 the 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
228 The
229 .Nm
230 command appeared in
231 .Ox 3.0 .
232 .Sh AUTHORS
233 .Nm
234 was written by
235 .An Can Erkin Acar Aq canacar@openbsd.org .