]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - contrib/pf/man/pfsync.4
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / contrib / pf / man / pfsync.4
1 .\"     $OpenBSD: pfsync.4,v 1.24 2006/10/23 07:05:49 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 .\" $FreeBSD$
28 .\"
29 .Dd June 6, 2006
30 .Dt PFSYNC 4
31 .Os
32 .Sh NAME
33 .Nm pfsync
34 .Nd packet filter state table logging interface
35 .Sh SYNOPSIS
36 .Cd "device pfsync"
37 .Sh DESCRIPTION
38 The
39 .Nm
40 interface is a pseudo-device which exposes certain changes to the state
41 table used by
42 .Xr pf 4 .
43 .\" XXX: not yet!
44 .\" State changes can be viewed by invoking
45 .\" .Xr tcpdump 1
46 .\" on the
47 .\" .Nm
48 .\" interface.
49 If configured with a physical synchronisation interface,
50 .Nm
51 will send state changes out on that interface using IP multicast,
52 and insert state changes received on that interface from other systems
53 into the state table.
54 .Pp
55 By default, all local changes to the state table are exposed via
56 .Nm .
57 However, state changes from packets received by
58 .Nm
59 over the network are not rebroadcast.
60 States created by a rule marked with the
61 .Ar no-sync
62 keyword are omitted from the
63 .Nm
64 interface (see
65 .Xr pf.conf 5
66 for details).
67 .Pp
68 The
69 .Nm
70 interface will attempt to collapse multiple updates of the same
71 state into one message where possible.
72 The maximum number of times this can be done before the update is sent out
73 is controlled by the
74 .Ar maxupd
75 parameter to ifconfig
76 (see
77 .Xr ifconfig 8
78 and the example below for more details).
79 .Pp
80 Each packet retrieved on this interface has a header associated
81 with it of length
82 .Dv PFSYNC_HDRLEN .
83 The header indicates the version of the protocol, address family,
84 action taken on the following states, and the number of state
85 table entries attached in this packet.
86 This structure is defined in
87 .Aq Pa net/if_pfsync.h
88 as:
89 .Bd -literal -offset indent
90 struct pfsync_header {
91         u_int8_t version;
92         u_int8_t af;
93         u_int8_t action;
94         u_int8_t count;
95 };
96 .Ed
97 .Sh NETWORK SYNCHRONISATION
98 States can be synchronised between two or more firewalls using this
99 interface, by specifying a synchronisation interface using
100 .Xr ifconfig 8 .
101 For example, the following command sets fxp0 as the synchronisation
102 interface:
103 .Bd -literal -offset indent
104 # ifconfig pfsync0 syncdev fxp0
105 .Ed
106 .Pp
107 It is important that the underlying synchronisation interface is up
108 and has an IP address assigned.
109 .Pp
110 By default, state change messages are sent out on the synchronisation
111 interface using IP multicast packets.
112 The protocol is IP protocol 240, PFSYNC, and the multicast group
113 used is 224.0.0.240.
114 When a peer address is specified using the
115 .Ic syncpeer
116 keyword, the peer address is used as a destination for the pfsync traffic,
117 and the traffic can then be protected using
118 .Xr ipsec 4 .
119 In such a configuration, the syncdev should be set to the
120 .Xr enc 4
121 interface, as this is where the traffic arrives when it is decapsulated,
122 e.g.:
123 .Bd -literal -offset indent
124 # ifconfig pfsync0 syncpeer 10.0.0.2 syncdev enc0
125 .Ed
126 .Pp
127 It is important that the pfsync traffic be well secured
128 as there is no authentication on the protocol and it would
129 be trivial to spoof packets which create states, bypassing the pf ruleset.
130 Either run the pfsync protocol on a trusted network \- ideally  a network
131 dedicated to pfsync messages such as a crossover cable between two firewalls,
132 or specify a peer address and protect the traffic with
133 .Xr ipsec 4 .
134 .Pp
135 For
136 .Nm
137 to start its operation automatically at the system boot time,
138 .Va pfsync_enable
139 and
140 .Va pfsync_syncdev
141 variables should be used in
142 .Xr rc.conf 5 .
143 It is not advisable to set up
144 .Nm
145 with common network interface configuration variables of
146 .Xr rc.conf 5
147 because
148 .Nm
149 must start after its
150 .Cm syncdev ,
151 which cannot be always ensured in the latter case.
152 .\" XXX: not yet!
153 .\" .Pp
154 .\" There is a one-to-one correspondence between packets seen by
155 .\" .Xr bpf 4
156 .\" on the
157 .\" .Nm
158 .\" interface, and packets sent out on the synchronisation interface, i.e.\&
159 .\" a packet with 4 state deletion messages on
160 .\" .Nm
161 .\" means that the same 4 deletions were sent out on the synchronisation
162 .\" interface.
163 .\" However, the actual packet contents may differ as the messages
164 .\" sent over the network are "compressed" where possible, containing
165 .\" only the necessary information.
166 .Sh EXAMPLES
167 .Nm
168 and
169 .Xr carp 4
170 can be used together to provide automatic failover of a pair of firewalls
171 configured in parallel.
172 One firewall handles all traffic \- if it dies or
173 is shut down, the second firewall takes over automatically.
174 .Pp
175 Both firewalls in this example have three
176 .Xr sis 4
177 interfaces.
178 sis0 is the external interface, on the 10.0.0.0/24 subnet; sis1 is the
179 internal interface, on the 192.168.0.0/24 subnet; and sis2 is the
180 .Nm
181 interface, using the 192.168.254.0/24 subnet.
182 A crossover cable connects the two firewalls via their sis2 interfaces.
183 On all three interfaces, firewall A uses the .254 address, while firewall B
184 uses .253.
185 The interfaces are configured as follows (firewall A unless otherwise
186 indicated):
187 .Pp
188 Interfaces configuration in
189 .Pa /etc/rc.conf :
190 .Bd -literal -offset indent
191 network_interfaces="lo0 sis0 sis1 sis2"
192 cloned_interfaces="carp0 carp1"
193 ifconfig_sis0="10.0.0.254/24"
194 ifconfig_sis1="192.168.0.254/24"
195 ifconfig_sis2="192.168.254.254/24"
196 ifconfig_carp0="vhid 1 pass foo 10.0.0.1/24"
197 ifconfig_carp1="vhid 2 pass bar 192.168.0.1/24"
198 pfsync_enable="YES"
199 pfsync_syncdev="sis2"
200 .Ed
201 .Pp
202 .Xr pf 4
203 must also be configured to allow
204 .Nm
205 and
206 .Xr carp 4
207 traffic through.
208 The following should be added to the top of
209 .Pa /etc/pf.conf :
210 .Bd -literal -offset indent
211 pass quick on { sis2 } proto pfsync
212 pass on { sis0 sis1 } proto carp
213 .Ed
214 .Pp
215 If it is preferable that one firewall handle the traffic,
216 the
217 .Ar advskew
218 on the backup firewall's
219 .Xr carp 4
220 interfaces should be set to something higher than
221 the primary's.
222 For example, if firewall B is the backup, its
223 carp1 configuration would look like this:
224 .Bd -literal -offset indent
225 ifconfig_carp1="vhid 2 pass bar advskew 100 192.168.0.1/24"
226 .Ed
227 .Pp
228 The following must also be added to
229 .Pa /etc/sysctl.conf :
230 .Bd -literal -offset indent
231 net.inet.carp.preempt=1
232 .Ed
233 .Sh BUGS
234 Possibility to view state changes using
235 .Xr tcpdump 1
236 has not been ported from
237 .Ox
238 yet.
239 .Sh SEE ALSO
240 .Xr bpf 4 ,
241 .Xr carp 4 ,
242 .Xr ifconfig 8 ,
243 .Xr inet 4 ,
244 .Xr inet6 4 ,
245 .Xr ipsec 4 ,
246 .Xr netintro 4 ,
247 .Xr pf 4 ,
248 .Xr pf.conf 5 ,
249 .Xr protocols 5 ,
250 .Xr rc.conf 5
251 .Xr ifconfig 8 ,
252 .Xr ifstated 8 ,
253 .Xr tcpdump 8
254 .Sh HISTORY
255 The
256 .Nm
257 device first appeared in
258 .Ox 3.3 .
259 The
260 .Nm
261 device was imported to
262 .Fx 5.3 .