usb.4: Clean up a bit.
[dragonfly.git] / share / man / man4 / pfsync.4
blobaa02eec32d9ac1ffe7d06748e5645180c239c695
1 .\"     $OpenBSD: pfsync.4,v 1.27 2008/06/03 19:51:02 jmc Exp $
2 .\"
3 .\" Copyright (c) 2002 Michael Shalayeff
4 .\" Copyright (c) 2003-2004 Ryan McBride
5 .\" All rights reserved.
6 .\"
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
9 .\" are met:
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\"    notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
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 MIND,
22 .\" USE, 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 April 21, 2018
28 .Dt PFSYNC 4
29 .Os
30 .Sh NAME
31 .Nm pfsync
32 .Nd packet filter state table logging interface
33 .Sh SYNOPSIS
34 .Cd "device pfsync"
35 .Sh DESCRIPTION
36 The
37 .Nm
38 interface is a pseudo-device which exposes certain changes to the state
39 table used by
40 .Xr pf 4 .
41 State changes can be viewed by invoking
42 .Xr tcpdump 1
43 on the
44 .Nm
45 interface.
46 If configured with a physical synchronisation interface,
47 .Nm
48 will also send state changes out on that interface using IP multicast,
49 and insert state changes received on that interface from other systems
50 into the state table.
51 .Pp
52 By default, all local changes to the state table are exposed via
53 .Nm .
54 However, state changes from packets received by
55 .Nm
56 over the network are not rebroadcast.
57 States created by a rule marked with the
58 .Ar no-sync
59 keyword are omitted from the
60 .Nm
61 interface (see
62 .Xr pf.conf 5
63 for details).
64 .Pp
65 The
66 .Nm
67 interface will attempt to collapse multiple updates of the same
68 state into one message where possible.
69 The maximum number of times this can be done before the update is sent out
70 is controlled by the
71 .Ar maxupd
72 parameter to ifconfig
73 (see
74 .Xr ifconfig 8
75 and the example below for more details).
76 .Pp
77 Each packet retrieved on this interface has a header associated
78 with it of length
79 .Dv PFSYNC_HDRLEN .
80 The header indicates the version of the protocol, address family,
81 action taken on the following states, and the number of state
82 table entries attached in this packet.
83 This structure is defined in
84 .Aq Pa net/pf/if_pfsync.h
85 as:
86 .Bd -literal -offset indent
87 struct pfsync_header {
88         u_int8_t version;
89         u_int8_t af;
90         u_int8_t action;
91         u_int8_t count;
93 .Ed
94 .Sh NETWORK SYNCHRONISATION
95 States can be synchronised between two or more firewalls using this
96 interface, by specifying a synchronisation interface using
97 .Xr ifconfig 8 .
98 For example, the following command sets fxp0 as the synchronisation
99 interface:
100 .Bd -literal -offset indent
101 # ifconfig pfsync0 syncdev fxp0
104 By default, state change messages are sent out on the synchronisation
105 interface using IP multicast packets.
106 The protocol is IP protocol 240, PFSYNC, and the multicast group
107 used is 224.0.0.240.
108 An alternative destination address for
110 packets can be specified using the
111 .Ic syncpeer
112 keyword.
114 It is important that the pfsync traffic be well secured
115 as there is no authentication on the protocol and it would
116 be trivial to spoof packets which create states, bypassing the pf ruleset.
117 Either run the pfsync protocol on a trusted network \- ideally a network
118 dedicated to pfsync messages such as a crossover cable between two firewalls.
120 There is a one-to-one correspondence between packets seen by
121 .Xr bpf 4
122 on the
124 interface, and packets sent out on the synchronisation interface, i.e.\&
125 a packet with 4 state deletion messages on
127 means that the same 4 deletions were sent out on the synchronisation
128 interface.
129 However, the actual packet contents may differ as the messages
130 sent over the network are "compressed" where possible, containing
131 only the necessary information.
132 .Sh EXAMPLES
133 .Bd -literal -offset indent
134 # ifconfig pfsync0 up syncif fxp0 maxupd 64
135 # tcpdump -s1500 -evtni pfsync0
137 .Sh USING PFSYNC WITH CARP
140 .Xr carp 4
141 can be used together to provide automatic failover of a pair of firewalls
142 configured in parallel.
143 One firewall handles all traffic \- if it dies or
144 is shut down, the second firewall takes over automatically.
146 Both firewalls in this example have three
147 .Xr sis 4
148 interfaces.
149 sis0 is the external interface, on the 10.0.0.0/24 subnet; sis1 is the
150 internal interface, on the 192.168.0.0/24 subnet; and sis2 is the
152 interface, using the 192.168.254.0/24 subnet.
153 A crossover cable connects the two firewalls via their sis2 interfaces.
154 On all three interfaces, firewall A uses the .254 address, while firewall B
155 uses .253.
156 The interfaces are configured as follows (firewall A unless otherwise
157 indicated):
159 Interfaces configuration in
160 .Pa /etc/rc.conf :
161 .Bd -literal -offset indent
162 network_interfaces="lo0 sis0 sis1 sis2"
163 cloned_interfaces="carp0 carp1"
164 ifconfig_sis0="10.0.0.254/24"
165 ifconfig_sis1="192.168.0.254/24"
166 ifconfig_sis2="192.168.254.254/24"
167 ifconfig_carp0="vhid 1 pass foo 10.0.0.1/24"
168 ifconfig_carp1="vhid 2 pass bar 192.168.0.1/24"
169 pfsync_enable="YES"
170 pfsync_syncdev="sis2"
173 .Xr pf 4
174 must also be configured to allow
177 .Xr carp 4
178 traffic through.
179 The following should be added to the top of
180 .Pa /etc/pf.conf :
181 .Bd -literal -offset indent
182 pass quick on { sis2 } proto pfsync keep state (no-sync)
183 pass on { sis0 sis1 } proto carp keep state (no-sync)
186 If it is preferable that one firewall handle the traffic,
188 .Ar advskew
189 on the backup firewall's
190 .Xr carp 4
191 interfaces should be set to something higher than
192 the primary's.
193 For example, if firewall B is the backup, its
194 carp1 configuration would look like this:
195 .Bd -literal -offset indent
196 ifconfig_carp1="vhid 2 pass bar advskew 100 192.168.0.1/24"
199 The following must also be added to
200 .Pa /etc/sysctl.conf :
201 .Bd -literal -offset indent
202 net.inet.carp.preempt=1
204 .Sh SEE ALSO
205 .Xr tcpdump 1 ,
206 .Xr bpf 4 ,
207 .Xr carp 4 ,
208 .Xr inet 4 ,
209 .Xr inet6 4 ,
210 .Xr netintro 4 ,
211 .Xr pf 4 ,
212 .Xr pf.conf 5 ,
213 .Xr protocols 5 ,
214 .Xr ifconfig 8
215 .\".Xr ifstated 8 ,
216 .Sh HISTORY
219 device first appeared in
220 .Ox 3.3
221 and was imported into
222 .Dx 1.1
223 by Devon H. O'Dell and Simon Schubert.