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