xref: /freebsd/share/man/man4/pflog.4 (revision 61e21613)
1.\"	$OpenBSD: pflog.4,v 1.10 2007/05/31 19:19:51 jmc Exp $
2.\"
3.\" Copyright (c) 2001 Tobias Weingartner
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.Dd October 29, 2021
27.Dt PFLOG 4
28.Os
29.Sh NAME
30.Nm pflog
31.Nd packet filter logging interface
32.Sh SYNOPSIS
33.Cd "device pflog"
34.Sh DESCRIPTION
35The
36.Nm pflog
37interface is a device which makes visible all packets logged by
38the packet filter,
39.Xr pf 4 .
40Logged packets can easily be monitored in real
41time by invoking
42.Xr tcpdump 1
43on the
44.Nm
45interface, or stored to disk using
46.Xr pflogd 8 .
47.Pp
48The pflog0 interface is created when the
49.Nm
50module is loaded;
51further instances can be created using
52.Xr ifconfig 8 .
53The
54.Nm
55module is loaded automatically if both
56.Xr pf 4
57and
58.Xr pflogd 8
59are enabled.
60.Pp
61Each packet retrieved on this interface has a header associated
62with it of length
63.Dv PFLOG_HDRLEN .
64This header documents the address family, interface name, rule
65number, reason, action, and direction of the packet that was logged.
66This structure, defined in
67.Aq Pa net/if_pflog.h
68looks like
69.Bd -literal -offset indent
70struct pfloghdr {
71	u_int8_t	length;
72	sa_family_t	af;
73	u_int8_t	action;
74	u_int8_t	reason;
75	char		ifname[IFNAMSIZ];
76	char		ruleset[PF_RULESET_NAME_SIZE];
77	u_int32_t	rulenr;
78	u_int32_t	subrulenr;
79	uid_t		uid;
80	pid_t		pid;
81	uid_t		rule_uid;
82	pid_t		rule_pid;
83	u_int8_t	dir;
84	u_int8_t	pad[3];
85	u_int32_t	ridentifier;
86};
87.Ed
88.Sh EXAMPLES
89Create a
90.Nm
91interface
92and monitor all packets logged on it:
93.Bd -literal -offset indent
94# ifconfig pflog create
95pflog1
96# ifconfig pflog1 up
97# tcpdump -n -e -ttt -i pflog1
98.Ed
99.Sh SEE ALSO
100.Xr tcpdump 1 ,
101.Xr inet 4 ,
102.Xr inet6 4 ,
103.Xr netintro 4 ,
104.Xr pf 4 ,
105.Xr ifconfig 8 ,
106.Xr pflogd 8
107.Sh HISTORY
108The
109.Nm
110device first appeared in
111.Ox 3.0 .
112.Sh BUGS
113FreeBSD does not set a process id in the
114.Fa pid
115field in pfloghdr.
116