1e0bfbfceSBjoern A. Zeeb.\" $OpenBSD: pflogd.8,v 1.37 2008/10/22 08:16:49 henning Exp $ 213b9f610SMax Laier.\" 313b9f610SMax Laier.\" Copyright (c) 2001 Can Erkin Acar. All rights reserved. 413b9f610SMax Laier.\" 513b9f610SMax Laier.\" Redistribution and use in source and binary forms, with or without 613b9f610SMax Laier.\" modification, are permitted provided that the following conditions 713b9f610SMax Laier.\" are met: 813b9f610SMax Laier.\" 1. Redistributions of source code must retain the above copyright 913b9f610SMax Laier.\" notice, this list of conditions and the following disclaimer. 1013b9f610SMax Laier.\" 2. Redistributions in binary form must reproduce the above copyright 1113b9f610SMax Laier.\" notice, this list of conditions and the following disclaimer in the 1213b9f610SMax Laier.\" documentation and/or other materials provided with the distribution. 1313b9f610SMax Laier.\" 3. The name of the author may not be used to endorse or promote products 1413b9f610SMax Laier.\" derived from this software without specific prior written permission. 1513b9f610SMax Laier.\" 1613b9f610SMax Laier.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 1713b9f610SMax Laier.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 1813b9f610SMax Laier.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 1913b9f610SMax Laier.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 2013b9f610SMax Laier.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 2113b9f610SMax Laier.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 2213b9f610SMax Laier.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 2313b9f610SMax Laier.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2413b9f610SMax Laier.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 2513b9f610SMax Laier.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2613b9f610SMax Laier.\" 27819f8dfaSChristian Brueffer.\" $FreeBSD$ 28819f8dfaSChristian Brueffer.\" 29*2bda7550SSevan Janiyan.Dd August 11, 2018 3013b9f610SMax Laier.Dt PFLOGD 8 3113b9f610SMax Laier.Os 3213b9f610SMax Laier.Sh NAME 3313b9f610SMax Laier.Nm pflogd 3413b9f610SMax Laier.Nd packet filter logging daemon 3513b9f610SMax Laier.Sh SYNOPSIS 3613b9f610SMax Laier.Nm pflogd 37e0bfbfceSBjoern A. Zeeb.Bk -words 38*2bda7550SSevan Janiyan.Op Fl \&Dx 3913b9f610SMax Laier.Op Fl d Ar delay 4013b9f610SMax Laier.Op Fl f Ar filename 415ee7cd21SMax Laier.Op Fl i Ar interface 4213b9f610SMax Laier.Op Fl s Ar snaplen 4313b9f610SMax Laier.Op Ar expression 44e0bfbfceSBjoern A. Zeeb.Ek 4513b9f610SMax Laier.Sh DESCRIPTION 4613b9f610SMax Laier.Nm 4713b9f610SMax Laieris a background daemon which reads packets logged by 4813b9f610SMax Laier.Xr pf 4 495ee7cd21SMax Laierto a 505ee7cd21SMax Laier.Xr pflog 4 515ee7cd21SMax Laierinterface, normally 525ee7cd21SMax Laier.Pa pflog0 , 5313b9f610SMax Laierand writes the packets to a logfile (normally 5413b9f610SMax Laier.Pa /var/log/pflog ) 5513b9f610SMax Laierin 56819f8dfaSChristian Brueffer.Xr tcpdump 1 5713b9f610SMax Laierbinary format. 5813b9f610SMax LaierThese logs can be reviewed later using the 5913b9f610SMax Laier.Fl r 6013b9f610SMax Laieroption of 61819f8dfaSChristian Brueffer.Xr tcpdump 1 , 6213b9f610SMax Laierhopefully offline in case there are bugs in the packet parsing code of 63819f8dfaSChristian Brueffer.Xr tcpdump 1 . 6413b9f610SMax Laier.Pp 6513b9f610SMax Laier.Nm 6613b9f610SMax Laiercloses and then re-opens the log file when it receives 67abff3868SMax Laier.Dv SIGHUP , 6813b9f610SMax Laierpermitting 6913b9f610SMax Laier.Xr newsyslog 8 7013b9f610SMax Laierto rotate logfiles automatically. 71abff3868SMax Laier.Dv SIGALRM 7213b9f610SMax Laiercauses 7313b9f610SMax Laier.Nm 7413b9f610SMax Laierto flush the current logfile buffers to the disk, thus making the most 7513b9f610SMax Laierrecent logs available. 7613b9f610SMax LaierThe buffers are also flushed every 7713b9f610SMax Laier.Ar delay 7813b9f610SMax Laierseconds. 7913b9f610SMax Laier.Pp 8013b9f610SMax LaierIf the log file contains data after a restart or a 81abff3868SMax Laier.Dv SIGHUP , 8213b9f610SMax Laiernew logs are appended to the existing file. 8313b9f610SMax LaierIf the existing log file was created with a different snaplen, 8413b9f610SMax Laier.Nm 8513b9f610SMax Laiertemporarily uses the old snaplen to keep the log file consistent. 8613b9f610SMax Laier.Pp 87abff3868SMax Laier.Nm 88abff3868SMax Laiertries to preserve the integrity of the log file against I/O errors. 89abff3868SMax LaierFurthermore, integrity of an existing log file is verified before 90abff3868SMax Laierappending. 915ee7cd21SMax LaierIf there is an invalid log file or an I/O error, the log file is moved 925ee7cd21SMax Laierout of the way and a new one is created. 935ee7cd21SMax LaierIf a new file cannot be created, logging is suspended until a 94abff3868SMax Laier.Dv SIGHUP 95abff3868SMax Laieror a 96abff3868SMax Laier.Dv SIGALRM 97abff3868SMax Laieris received. 98abff3868SMax Laier.Pp 99e0bfbfceSBjoern A. Zeeb.Nm 100e0bfbfceSBjoern A. Zeebwill also log the pcap statistics for the 101e0bfbfceSBjoern A. Zeeb.Xr pflog 4 102e0bfbfceSBjoern A. Zeebinterface to syslog when a 103e0bfbfceSBjoern A. Zeeb.Dv SIGUSR1 104e0bfbfceSBjoern A. Zeebis received. 105e0bfbfceSBjoern A. Zeeb.Pp 10613b9f610SMax LaierThe options are as follows: 10713b9f610SMax Laier.Bl -tag -width Ds 10813b9f610SMax Laier.It Fl D 10913b9f610SMax LaierDebugging mode. 11013b9f610SMax Laier.Nm 11113b9f610SMax Laierdoes not disassociate from the controlling terminal. 112abff3868SMax Laier.It Fl d Ar delay 113abff3868SMax LaierTime in seconds to delay between automatic flushes of the file. 114abff3868SMax LaierThis may be specified with a value between 5 and 3600 seconds. 115abff3868SMax LaierIf not specified, the default is 60 seconds. 11613b9f610SMax Laier.It Fl f Ar filename 11713b9f610SMax LaierLog output filename. 11813b9f610SMax LaierDefault is 11913b9f610SMax Laier.Pa /var/log/pflog . 1205ee7cd21SMax Laier.It Fl i Ar interface 1215ee7cd21SMax LaierSpecifies the 1225ee7cd21SMax Laier.Xr pflog 4 1235ee7cd21SMax Laierinterface to use. 1245ee7cd21SMax LaierBy default, 1255ee7cd21SMax Laier.Nm 1265ee7cd21SMax Laierwill use 1275ee7cd21SMax Laier.Ar pflog0 . 12862c332ceSWarren Block.It Fl p Ar pidfile 129e0bfbfceSBjoern A. ZeebWrites a file containing the process ID of the program to 130e0bfbfceSBjoern A. Zeeb.Pa /var/run . 131e0bfbfceSBjoern A. ZeebThe file name has the form 13262c332ceSWarren Block.Ao Ar pidfile Ac Ns .pid . 133e0bfbfceSBjoern A. ZeebThe default is 134e0bfbfceSBjoern A. Zeeb.Ar pflogd . 13513b9f610SMax Laier.It Fl s Ar snaplen 13613b9f610SMax LaierAnalyze at most the first 13713b9f610SMax Laier.Ar snaplen 1385ee7cd21SMax Laierbytes of data from each packet rather than the default of 116. 1395ee7cd21SMax LaierThe default of 116 is adequate for IP, ICMP, TCP, and UDP headers but may 14013b9f610SMax Laiertruncate protocol information for other protocols. 14113b9f610SMax LaierOther file parsers may desire a higher snaplen. 142abff3868SMax Laier.It Fl x 143abff3868SMax LaierCheck the integrity of an existing log file, and return. 14413b9f610SMax Laier.It Ar expression 14513b9f610SMax LaierSelects which packets will be dumped, using the regular language of 146819f8dfaSChristian Brueffer.Xr tcpdump 1 . 14713b9f610SMax Laier.El 14813b9f610SMax Laier.Sh FILES 14913b9f610SMax Laier.Bl -tag -width /var/run/pflogd.pid -compact 15013b9f610SMax Laier.It Pa /var/run/pflogd.pid 15113b9f610SMax LaierProcess ID of the currently running 152abff3868SMax Laier.Nm . 15313b9f610SMax Laier.It Pa /var/log/pflog 15413b9f610SMax LaierDefault log file. 15513b9f610SMax Laier.El 15613b9f610SMax Laier.Sh EXAMPLES 15713b9f610SMax LaierLog specific tcp packets to a different log file with a large snaplen 158abff3868SMax Laier(useful with a log-all rule to dump complete sessions): 15913b9f610SMax Laier.Bd -literal -offset indent 16013b9f610SMax Laier# pflogd -s 1600 -f suspicious.log port 80 and host evilhost 16113b9f610SMax Laier.Ed 16213b9f610SMax Laier.Pp 1635ee7cd21SMax LaierLog from another 1645ee7cd21SMax Laier.Xr pflog 4 1655ee7cd21SMax Laierinterface, excluding specific packets: 1665ee7cd21SMax Laier.Bd -literal -offset indent 1675ee7cd21SMax Laier# pflogd -i pflog3 -f network3.log "not (tcp and port 23)" 1685ee7cd21SMax Laier.Ed 1695ee7cd21SMax Laier.Pp 17013b9f610SMax LaierDisplay binary logs: 17113b9f610SMax Laier.Bd -literal -offset indent 17213b9f610SMax Laier# tcpdump -n -e -ttt -r /var/log/pflog 17313b9f610SMax Laier.Ed 17413b9f610SMax Laier.Pp 17513b9f610SMax LaierDisplay the logs in real time (this does not interfere with the 176abff3868SMax Laieroperation of 177abff3868SMax Laier.Nm ) : 17813b9f610SMax Laier.Bd -literal -offset indent 17913b9f610SMax Laier# tcpdump -n -e -ttt -i pflog0 18013b9f610SMax Laier.Ed 18113b9f610SMax Laier.Pp 18213b9f610SMax LaierTcpdump has been extended to be able to filter on the pfloghdr 18313b9f610SMax Laierstructure defined in 18413b9f610SMax Laier.Aq Ar net/if_pflog.h . 18513b9f610SMax LaierTcpdump can restrict the output 18613b9f610SMax Laierto packets logged on a specified interface, a rule number, a reason, 187abff3868SMax Laiera direction, an IP family or an action. 18813b9f610SMax Laier.Pp 1895ee7cd21SMax Laier.Bl -tag -width "ruleset authpf " -compact 19013b9f610SMax Laier.It ip 19113b9f610SMax LaierAddress family equals IPv4. 19213b9f610SMax Laier.It ip6 19313b9f610SMax LaierAddress family equals IPv6. 19413b9f610SMax Laier.It ifname kue0 195abff3868SMax LaierInterface name equals "kue0". 19613b9f610SMax Laier.It on kue0 197abff3868SMax LaierInterface name equals "kue0". 1985ee7cd21SMax Laier.It ruleset authpf 1995ee7cd21SMax LaierRuleset name equals "authpf". 20013b9f610SMax Laier.It rulenum 10 20113b9f610SMax LaierRule number equals 10. 20213b9f610SMax Laier.It reason match 20313b9f610SMax LaierReason equals match. 20461a1372bSMax LaierAlso accepts "bad-offset", "fragment", "bad-timestamp", "short", 2055ee7cd21SMax Laier"normalize", "memory", "congestion", "ip-option", "proto-cksum", 2065ee7cd21SMax Laier"state-mismatch", "state-insert", "state-limit", "src-limit", 2075ee7cd21SMax Laierand "synproxy". 20813b9f610SMax Laier.It action pass 20913b9f610SMax LaierAction equals pass. 21013b9f610SMax LaierAlso accepts "block". 21113b9f610SMax Laier.It inbound 21213b9f610SMax LaierThe direction was inbound. 21313b9f610SMax Laier.It outbound 21413b9f610SMax LaierThe direction was outbound. 21513b9f610SMax Laier.El 21613b9f610SMax Laier.Pp 21713b9f610SMax LaierDisplay the logs in real time of inbound packets that were blocked on 21813b9f610SMax Laierthe wi0 interface: 21913b9f610SMax Laier.Bd -literal -offset indent 22013b9f610SMax Laier# tcpdump -n -e -ttt -i pflog0 inbound and action block and on wi0 22113b9f610SMax Laier.Ed 22213b9f610SMax Laier.Sh SEE ALSO 22313b9f610SMax Laier.Xr pcap 3 , 22413b9f610SMax Laier.Xr pf 4 , 22513b9f610SMax Laier.Xr pflog 4 , 22613b9f610SMax Laier.Xr pf.conf 5 , 227e0bfbfceSBjoern A. Zeeb.Xr newsyslog 8 , 228e0bfbfceSBjoern A. Zeeb.Xr tcpdump 1 22913b9f610SMax Laier.Sh HISTORY 23013b9f610SMax LaierThe 23113b9f610SMax Laier.Nm 23213b9f610SMax Laiercommand appeared in 23313b9f610SMax Laier.Ox 3.0 . 23413b9f610SMax Laier.Sh AUTHORS 2355ee7cd21SMax Laier.Nm 2365ee7cd21SMax Laierwas written by 2375ee7cd21SMax Laier.An Can Erkin Acar Aq canacar@openbsd.org . 238