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