xref: /openbsd-src/share/man/man4/pfsync.4 (revision a28daedfc357b214be5c701aa8ba8adb29a7f1c2)
1.\"	$OpenBSD: pfsync.4,v 1.28 2009/02/17 10:05:18 dlg 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 $Mdocdate: February 17 2009 $
28.Dt PFSYNC 4
29.Os
30.Sh NAME
31.Nm pfsync
32.Nd packet filter state table sychronisation interface
33.Sh SYNOPSIS
34.Cd "pseudo-device pfsync"
35.Sh DESCRIPTION
36The
37.Nm
38interface is a pseudo-device which exposes certain changes to the state
39table used by
40.Xr pf 4 .
41State changes can be viewed by invoking
42.Xr tcpdump 8
43on the
44.Nm
45interface.
46If configured with a physical synchronisation interface,
47.Nm
48will also send state changes out on that interface,
49and insert state changes received on that interface from other systems
50into the state table.
51.Pp
52By default, all local changes to the state table are exposed via
53.Nm .
54State changes from packets received by
55.Nm
56over the network are not rebroadcast.
57Updates to states created by a rule marked with the
58.Ar no-sync
59keyword are ignored by the
60.Nm
61interface (see
62.Xr pf.conf 5
63for details).
64.Pp
65The
66.Nm
67interface will attempt to collapse multiple state updates into a single
68packet where possible.
69The maximum number of times a single state can be updated before a
70.Nm
71packet will be sent out is controlled by the
72.Ar maxupd
73parameter to ifconfig
74(see
75.Xr ifconfig 8
76and the example below for more details).
77The sending out of a
78.Nm
79packet will be delayed by a maximum of one second.
80.Sh NETWORK SYNCHRONISATION
81States can be synchronised between two or more firewalls using this
82interface, by specifying a synchronisation interface using
83.Xr ifconfig 8 .
84For example, the following command sets fxp0 as the synchronisation
85interface:
86.Bd -literal -offset indent
87# ifconfig pfsync0 syncdev fxp0
88.Ed
89.Pp
90By default, state change messages are sent out on the synchronisation
91interface using IP multicast packets to the 244.0.0.240 group address.
92An alternative destination address for
93.Nm
94packets can be specified using the
95.Ic syncpeer
96keyword.
97This can be used in combination with
98.Xr ipsec 4
99to protect the synchronisation traffic.
100In such a configuration, the syncdev should be set to the
101.Xr enc 4
102interface, as this is where the traffic arrives when it is decapsulated,
103e.g.:
104.Bd -literal -offset indent
105# ifconfig pfsync0 syncpeer 10.0.0.2 syncdev enc0
106.Ed
107.Pp
108It is important that the pfsync traffic be well secured
109as there is no authentication on the protocol and it would
110be trivial to spoof packets which create states, bypassing the pf ruleset.
111Either run the pfsync protocol on a trusted network \- ideally a network
112dedicated to pfsync messages such as a crossover cable between two firewalls,
113or specify a peer address and protect the traffic with
114.Xr ipsec 4 .
115.Sh EXAMPLES
116.Nm
117and
118.Xr carp 4
119can be used together to provide automatic failover of a pair of firewalls
120configured in parallel.
121One firewall will handle all traffic until it dies, is shut down, or is
122manually demoted, at which point the second firewall will take over
123automatically.
124.Pp
125Both firewalls in this example have three
126.Xr sis 4
127interfaces.
128sis0 is the external interface, on the 10.0.0.0/24 subnet; sis1 is the
129internal interface, on the 192.168.0.0/24 subnet; and sis2 is the
130.Nm
131interface, using the 192.168.254.0/24 subnet.
132A crossover cable connects the two firewalls via their sis2 interfaces.
133On all three interfaces, firewall A uses the .254 address, while firewall B
134uses .253.
135The interfaces are configured as follows (firewall A unless otherwise
136indicated):
137.Pp
138.Pa /etc/hostname.sis0 :
139.Bd -literal -offset indent
140inet 10.0.0.254 255.255.255.0 NONE
141.Ed
142.Pp
143.Pa /etc/hostname.sis1 :
144.Bd -literal -offset indent
145inet 192.168.0.254 255.255.255.0 NONE
146.Ed
147.Pp
148.Pa /etc/hostname.sis2 :
149.Bd -literal -offset indent
150inet 192.168.254.254 255.255.255.0 NONE
151.Ed
152.Pp
153.Pa /etc/hostname.carp0 :
154.Bd -literal -offset indent
155inet 10.0.0.1 255.255.255.0 10.0.0.255 vhid 1 pass foo
156.Ed
157.Pp
158.Pa /etc/hostname.carp1 :
159.Bd -literal -offset indent
160inet 192.168.0.1 255.255.255.0 192.168.0.255 vhid 2 pass bar
161.Ed
162.Pp
163.Pa /etc/hostname.pfsync0 :
164.Bd -literal -offset indent
165up syncdev sis2
166.Ed
167.Pp
168.Xr pf 4
169must also be configured to allow
170.Nm
171and
172.Xr carp 4
173traffic through.
174The following should be added to the top of
175.Pa /etc/pf.conf :
176.Bd -literal -offset indent
177pass quick on { sis2 } proto pfsync keep state (no-sync)
178pass on { sis0 sis1 } proto carp keep state (no-sync)
179.Ed
180.Pp
181It is preferable that one firewall handle the forwarding of all the traffic,
182therefore the
183.Ar advskew
184on the backup firewall's
185.Xr carp 4
186interfaces should be set to something higher than
187the primary's.
188For example, if firewall B is the backup, its
189.Pa /etc/hostname.carp1
190would look like this:
191.Bd -literal -offset indent
192inet 192.168.0.1 255.255.255.0 192.168.0.255 vhid 2 pass bar \e
193	advskew 100
194.Ed
195.Pp
196The following must also be added to
197.Pa /etc/sysctl.conf :
198.Bd -literal -offset indent
199net.inet.carp.preempt=1
200.Ed
201.Sh SEE ALSO
202.Xr bpf 4 ,
203.Xr carp 4 ,
204.Xr enc 4 ,
205.Xr inet 4 ,
206.Xr inet6 4 ,
207.Xr ipsec 4 ,
208.Xr netintro 4 ,
209.Xr pf 4 ,
210.Xr hostname.if 5 ,
211.Xr pf.conf 5 ,
212.Xr protocols 5 ,
213.Xr ifconfig 8 ,
214.Xr ifstated 8 ,
215.Xr tcpdump 8
216.Sh HISTORY
217The
218.Nm
219device first appeared in
220.Ox 3.3 .
221.Pp
222The
223.Nm
224protocol and kernel implementation were significantly modified between
225.Ox 4.4
226and
227.Ox 4.5 .
228The two protocols are incompatible and will not interoperate.
229