1.\" $OpenBSD: pflogd.8,v 1.46 2014/01/21 03:15:45 schwarze 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: January 21 2014 $ 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, the log file is moved 90out of the way and a new one is created. 91If a new file cannot be created, logging is suspended until a 92.Dv SIGHUP 93or a 94.Dv SIGALRM 95is received. 96.Pp 97.Nm 98will also log the pcap statistics for the 99.Xr pflog 4 100interface to syslog when a 101.Dv SIGUSR1 102is received. 103.Pp 104The options are as follows: 105.Bl -tag -width Ds 106.It Fl D 107Debugging mode. 108.Nm 109does not disassociate from the controlling terminal. 110.It Fl d Ar delay 111Time in seconds to delay between automatic flushes of the file. 112This may be specified with a value between 5 and 3600 seconds. 113If not specified, the default is 60 seconds. 114.It Fl f Ar filename 115Log output filename. 116Default is 117.Pa /var/log/pflog . 118.It Fl i Ar interface 119Specifies the 120.Xr pflog 4 121interface to use. 122By default, 123.Nm 124will use 125.Pa pflog0 . 126.It Fl s Ar snaplen 127Analyze at most the first 128.Ar snaplen 129bytes of data from each packet rather than the default of 160. 130The default of 160 is adequate for IP, ICMP, TCP, and UDP headers but may 131truncate protocol information for other protocols. 132Other file parsers may desire a higher snaplen. 133.It Fl x 134Check the integrity of an existing log file, and return. 135.It Ar expression 136Selects which packets will be dumped, using the regular language of 137.Xr tcpdump 8 . 138Tcpdump has been extended to be able to filter on the pfloghdr 139structure defined in 140.Aq Ar net/if_pflog.h . 141It can restrict the output 142to packets logged on a specified interface, a rule number, a reason, 143a direction, an IP family or an action. 144.Pp 145.Bl -tag -width "ruleset authpfXXX" -offset 3n -compact 146.It ip 147Address family equals IPv4. 148.It ip6 149Address family equals IPv6. 150.It ifname kue0 151Interface name equals "kue0". 152.It on kue0 153Interface name equals "kue0". 154.It ruleset authpf 155Ruleset name equals "authpf". 156.It rulenum 10 157Rule number equals 10. 158.It reason match 159Reason equals match. 160Also accepts "bad-offset", "fragment", "short", "normalize", 161"memory", "bad-timestamp", "congestion", "ip-option", "proto-cksum", 162"state-mismatch", "state-insert", "state-limit", "src-limit", 163and "synproxy". 164.It action pass 165Action equals pass. 166Also accepts "block" and "match". 167.It inbound 168The direction was inbound. 169.It outbound 170The direction was outbound. 171.El 172.El 173.Sh FILES 174.Bl -tag -width /var/run/pflogd.pid -compact 175.It Pa /var/log/pflog 176Default log file. 177.El 178.Sh EXAMPLES 179Log specific TCP packets to a different log file with a large snaplen 180(useful with a 181.Qq log all 182rule to dump complete sessions): 183.Bd -literal -offset indent 184# pflogd -s 1600 -f suspicious.log port 80 and host evilhost 185.Ed 186.Pp 187Log from another 188.Xr pflog 4 189interface, excluding specific packets: 190.Bd -literal -offset indent 191# pflogd -i pflog3 -f network3.log "not (tcp and port 23)" 192.Ed 193.Pp 194Display binary logs: 195.Bd -literal -offset indent 196# tcpdump -n -e -ttt -r /var/log/pflog 197.Ed 198.Pp 199Display the logs in real time (this does not interfere with the 200operation of 201.Nm ) : 202.Bd -literal -offset indent 203# tcpdump -n -e -ttt -i pflog0 204.Ed 205.Pp 206Display the logs in real time of inbound packets that were blocked on 207the wi0 interface: 208.Bd -literal -offset indent 209# tcpdump -n -e -ttt -i pflog0 inbound and action block and on wi0 210.Ed 211.Sh SEE ALSO 212.Xr pcap 3 , 213.Xr pf 4 , 214.Xr pflog 4 , 215.Xr pf.conf 5 , 216.Xr newsyslog 8 , 217.Xr tcpdump 8 218.Sh HISTORY 219The 220.Nm 221command appeared in 222.Ox 3.0 . 223.Sh AUTHORS 224.Nm 225was written by 226.An Can Erkin Acar Aq Mt canacar@openbsd.org . 227