1*3b3a8eb9SGleb Smirnoff.\" $OpenBSD: pfsync.4,v 1.28 2009/02/17 10:05:18 dlg Exp $ 2*3b3a8eb9SGleb Smirnoff.\" 3*3b3a8eb9SGleb Smirnoff.\" Copyright (c) 2002 Michael Shalayeff 4*3b3a8eb9SGleb Smirnoff.\" Copyright (c) 2003-2004 Ryan McBride 5*3b3a8eb9SGleb Smirnoff.\" All rights reserved. 6*3b3a8eb9SGleb Smirnoff.\" 7*3b3a8eb9SGleb Smirnoff.\" Redistribution and use in source and binary forms, with or without 8*3b3a8eb9SGleb Smirnoff.\" modification, are permitted provided that the following conditions 9*3b3a8eb9SGleb Smirnoff.\" are met: 10*3b3a8eb9SGleb Smirnoff.\" 1. Redistributions of source code must retain the above copyright 11*3b3a8eb9SGleb Smirnoff.\" notice, this list of conditions and the following disclaimer. 12*3b3a8eb9SGleb Smirnoff.\" 2. Redistributions in binary form must reproduce the above copyright 13*3b3a8eb9SGleb Smirnoff.\" notice, this list of conditions and the following disclaimer in the 14*3b3a8eb9SGleb Smirnoff.\" documentation and/or other materials provided with the distribution. 15*3b3a8eb9SGleb Smirnoff.\" 16*3b3a8eb9SGleb Smirnoff.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 17*3b3a8eb9SGleb Smirnoff.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 18*3b3a8eb9SGleb Smirnoff.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 19*3b3a8eb9SGleb Smirnoff.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 20*3b3a8eb9SGleb Smirnoff.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 21*3b3a8eb9SGleb Smirnoff.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF MIND, 22*3b3a8eb9SGleb Smirnoff.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23*3b3a8eb9SGleb Smirnoff.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24*3b3a8eb9SGleb Smirnoff.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 25*3b3a8eb9SGleb Smirnoff.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26*3b3a8eb9SGleb Smirnoff.\" 27*3b3a8eb9SGleb Smirnoff.\" $FreeBSD$ 28*3b3a8eb9SGleb Smirnoff.\" 29*3b3a8eb9SGleb Smirnoff.Dd December 20 2011 30*3b3a8eb9SGleb Smirnoff.Dt PFSYNC 4 31*3b3a8eb9SGleb Smirnoff.Os 32*3b3a8eb9SGleb Smirnoff.Sh NAME 33*3b3a8eb9SGleb Smirnoff.Nm pfsync 34*3b3a8eb9SGleb Smirnoff.Nd packet filter state table sychronisation interface 35*3b3a8eb9SGleb Smirnoff.Sh SYNOPSIS 36*3b3a8eb9SGleb Smirnoff.Cd "device pfsync" 37*3b3a8eb9SGleb Smirnoff.Sh DESCRIPTION 38*3b3a8eb9SGleb SmirnoffThe 39*3b3a8eb9SGleb Smirnoff.Nm 40*3b3a8eb9SGleb Smirnoffinterface is a pseudo-device which exposes certain changes to the state 41*3b3a8eb9SGleb Smirnofftable used by 42*3b3a8eb9SGleb Smirnoff.Xr pf 4 . 43*3b3a8eb9SGleb SmirnoffState changes can be viewed by invoking 44*3b3a8eb9SGleb Smirnoff.Xr tcpdump 1 45*3b3a8eb9SGleb Smirnoffon the 46*3b3a8eb9SGleb Smirnoff.Nm 47*3b3a8eb9SGleb Smirnoffinterface. 48*3b3a8eb9SGleb SmirnoffIf configured with a physical synchronisation interface, 49*3b3a8eb9SGleb Smirnoff.Nm 50*3b3a8eb9SGleb Smirnoffwill also send state changes out on that interface, 51*3b3a8eb9SGleb Smirnoffand insert state changes received on that interface from other systems 52*3b3a8eb9SGleb Smirnoffinto the state table. 53*3b3a8eb9SGleb Smirnoff.Pp 54*3b3a8eb9SGleb SmirnoffBy default, all local changes to the state table are exposed via 55*3b3a8eb9SGleb Smirnoff.Nm . 56*3b3a8eb9SGleb SmirnoffState changes from packets received by 57*3b3a8eb9SGleb Smirnoff.Nm 58*3b3a8eb9SGleb Smirnoffover the network are not rebroadcast. 59*3b3a8eb9SGleb SmirnoffUpdates to states created by a rule marked with the 60*3b3a8eb9SGleb Smirnoff.Ar no-sync 61*3b3a8eb9SGleb Smirnoffkeyword are ignored by the 62*3b3a8eb9SGleb Smirnoff.Nm 63*3b3a8eb9SGleb Smirnoffinterface (see 64*3b3a8eb9SGleb Smirnoff.Xr pf.conf 5 65*3b3a8eb9SGleb Smirnofffor details). 66*3b3a8eb9SGleb Smirnoff.Pp 67*3b3a8eb9SGleb SmirnoffThe 68*3b3a8eb9SGleb Smirnoff.Nm 69*3b3a8eb9SGleb Smirnoffinterface will attempt to collapse multiple state updates into a single 70*3b3a8eb9SGleb Smirnoffpacket where possible. 71*3b3a8eb9SGleb SmirnoffThe maximum number of times a single state can be updated before a 72*3b3a8eb9SGleb Smirnoff.Nm 73*3b3a8eb9SGleb Smirnoffpacket will be sent out is controlled by the 74*3b3a8eb9SGleb Smirnoff.Ar maxupd 75*3b3a8eb9SGleb Smirnoffparameter to ifconfig 76*3b3a8eb9SGleb Smirnoff(see 77*3b3a8eb9SGleb Smirnoff.Xr ifconfig 8 78*3b3a8eb9SGleb Smirnoffand the example below for more details). 79*3b3a8eb9SGleb SmirnoffThe sending out of a 80*3b3a8eb9SGleb Smirnoff.Nm 81*3b3a8eb9SGleb Smirnoffpacket will be delayed by a maximum of one second. 82*3b3a8eb9SGleb Smirnoff.Sh NETWORK SYNCHRONISATION 83*3b3a8eb9SGleb SmirnoffStates can be synchronised between two or more firewalls using this 84*3b3a8eb9SGleb Smirnoffinterface, by specifying a synchronisation interface using 85*3b3a8eb9SGleb Smirnoff.Xr ifconfig 8 . 86*3b3a8eb9SGleb SmirnoffFor example, the following command sets fxp0 as the synchronisation 87*3b3a8eb9SGleb Smirnoffinterface: 88*3b3a8eb9SGleb Smirnoff.Bd -literal -offset indent 89*3b3a8eb9SGleb Smirnoff# ifconfig pfsync0 syncdev fxp0 90*3b3a8eb9SGleb Smirnoff.Ed 91*3b3a8eb9SGleb Smirnoff.Pp 92*3b3a8eb9SGleb SmirnoffBy default, state change messages are sent out on the synchronisation 93*3b3a8eb9SGleb Smirnoffinterface using IP multicast packets to the 244.0.0.240 group address. 94*3b3a8eb9SGleb SmirnoffAn alternative destination address for 95*3b3a8eb9SGleb Smirnoff.Nm 96*3b3a8eb9SGleb Smirnoffpackets can be specified using the 97*3b3a8eb9SGleb Smirnoff.Ic syncpeer 98*3b3a8eb9SGleb Smirnoffkeyword. 99*3b3a8eb9SGleb SmirnoffThis can be used in combination with 100*3b3a8eb9SGleb Smirnoff.Xr ipsec 4 101*3b3a8eb9SGleb Smirnoffto protect the synchronisation traffic. 102*3b3a8eb9SGleb SmirnoffIn such a configuration, the syncdev should be set to the 103*3b3a8eb9SGleb Smirnoff.Xr enc 4 104*3b3a8eb9SGleb Smirnoffinterface, as this is where the traffic arrives when it is decapsulated, 105*3b3a8eb9SGleb Smirnoffe.g.: 106*3b3a8eb9SGleb Smirnoff.Bd -literal -offset indent 107*3b3a8eb9SGleb Smirnoff# ifconfig pfsync0 syncpeer 10.0.0.2 syncdev enc0 108*3b3a8eb9SGleb Smirnoff.Ed 109*3b3a8eb9SGleb Smirnoff.Pp 110*3b3a8eb9SGleb SmirnoffIt is important that the pfsync traffic be well secured 111*3b3a8eb9SGleb Smirnoffas there is no authentication on the protocol and it would 112*3b3a8eb9SGleb Smirnoffbe trivial to spoof packets which create states, bypassing the pf ruleset. 113*3b3a8eb9SGleb SmirnoffEither run the pfsync protocol on a trusted network \- ideally a network 114*3b3a8eb9SGleb Smirnoffdedicated to pfsync messages such as a crossover cable between two firewalls, 115*3b3a8eb9SGleb Smirnoffor specify a peer address and protect the traffic with 116*3b3a8eb9SGleb Smirnoff.Xr ipsec 4 . 117*3b3a8eb9SGleb Smirnoff.Pp 118*3b3a8eb9SGleb Smirnoff.Nm 119*3b3a8eb9SGleb Smirnoffhas the following 120*3b3a8eb9SGleb Smirnoff.Xr sysctl 8 121*3b3a8eb9SGleb Smirnofftunables: 122*3b3a8eb9SGleb Smirnoff.Bl -tag -width ".Va net.pfsync" 123*3b3a8eb9SGleb Smirnoff.It Va net.pfsync.carp_demotion_factor 124*3b3a8eb9SGleb SmirnoffValue added to 125*3b3a8eb9SGleb Smirnoff.Va net.inet.carp.demotion 126*3b3a8eb9SGleb Smirnoffwhile 127*3b3a8eb9SGleb Smirnoff.Nm 128*3b3a8eb9SGleb Smirnofftries to perform its bulk update. 129*3b3a8eb9SGleb SmirnoffSee 130*3b3a8eb9SGleb Smirnoff.Xr carp 4 131*3b3a8eb9SGleb Smirnofffor more information. 132*3b3a8eb9SGleb SmirnoffDefault value is 240. 133*3b3a8eb9SGleb Smirnoff.El 134*3b3a8eb9SGleb Smirnoff.Sh EXAMPLES 135*3b3a8eb9SGleb Smirnoff.Nm 136*3b3a8eb9SGleb Smirnoffand 137*3b3a8eb9SGleb Smirnoff.Xr carp 4 138*3b3a8eb9SGleb Smirnoffcan be used together to provide automatic failover of a pair of firewalls 139*3b3a8eb9SGleb Smirnoffconfigured in parallel. 140*3b3a8eb9SGleb SmirnoffOne firewall will handle all traffic until it dies, is shut down, or is 141*3b3a8eb9SGleb Smirnoffmanually demoted, at which point the second firewall will take over 142*3b3a8eb9SGleb Smirnoffautomatically. 143*3b3a8eb9SGleb Smirnoff.Pp 144*3b3a8eb9SGleb SmirnoffBoth firewalls in this example have three 145*3b3a8eb9SGleb Smirnoff.Xr sis 4 146*3b3a8eb9SGleb Smirnoffinterfaces. 147*3b3a8eb9SGleb Smirnoffsis0 is the external interface, on the 10.0.0.0/24 subnet; sis1 is the 148*3b3a8eb9SGleb Smirnoffinternal interface, on the 192.168.0.0/24 subnet; and sis2 is the 149*3b3a8eb9SGleb Smirnoff.Nm 150*3b3a8eb9SGleb Smirnoffinterface, using the 192.168.254.0/24 subnet. 151*3b3a8eb9SGleb SmirnoffA crossover cable connects the two firewalls via their sis2 interfaces. 152*3b3a8eb9SGleb SmirnoffOn all three interfaces, firewall A uses the .254 address, while firewall B 153*3b3a8eb9SGleb Smirnoffuses .253. 154*3b3a8eb9SGleb SmirnoffThe interfaces are configured as follows (firewall A unless otherwise 155*3b3a8eb9SGleb Smirnoffindicated): 156*3b3a8eb9SGleb Smirnoff.Pp 157*3b3a8eb9SGleb SmirnoffInterfaces configuration in 158*3b3a8eb9SGleb Smirnoff.Pa /etc/rc.conf : 159*3b3a8eb9SGleb Smirnoff.Bd -literal -offset indent 160*3b3a8eb9SGleb Smirnoffnetwork_interfaces="lo0 sis0 sis1 sis2" 161*3b3a8eb9SGleb Smirnoffifconfig_sis0="10.0.0.254/24" 162*3b3a8eb9SGleb Smirnoffifconfig_sis0_alias0="inet 10.0.0.1/24 vhid 1 pass foo" 163*3b3a8eb9SGleb Smirnoffifconfig_sis1="192.168.0.254/24" 164*3b3a8eb9SGleb Smirnoffifconfig_sis1_alias0="inet 192.168.0.1/24 vhid 2 pass bar" 165*3b3a8eb9SGleb Smirnoffifconfig_sis2="192.168.254.254/24" 166*3b3a8eb9SGleb Smirnoffpfsync_enable="YES" 167*3b3a8eb9SGleb Smirnoffpfsync_syncdev="sis2" 168*3b3a8eb9SGleb Smirnoff.Ed 169*3b3a8eb9SGleb Smirnoff.Pp 170*3b3a8eb9SGleb Smirnoff.Xr pf 4 171*3b3a8eb9SGleb Smirnoffmust also be configured to allow 172*3b3a8eb9SGleb Smirnoff.Nm 173*3b3a8eb9SGleb Smirnoffand 174*3b3a8eb9SGleb Smirnoff.Xr carp 4 175*3b3a8eb9SGleb Smirnofftraffic through. 176*3b3a8eb9SGleb SmirnoffThe following should be added to the top of 177*3b3a8eb9SGleb Smirnoff.Pa /etc/pf.conf : 178*3b3a8eb9SGleb Smirnoff.Bd -literal -offset indent 179*3b3a8eb9SGleb Smirnoffpass quick on { sis2 } proto pfsync keep state (no-sync) 180*3b3a8eb9SGleb Smirnoffpass on { sis0 sis1 } proto carp keep state (no-sync) 181*3b3a8eb9SGleb Smirnoff.Ed 182*3b3a8eb9SGleb Smirnoff.Pp 183*3b3a8eb9SGleb SmirnoffIt is preferable that one firewall handle the forwarding of all the traffic, 184*3b3a8eb9SGleb Smirnofftherefore the 185*3b3a8eb9SGleb Smirnoff.Ar advskew 186*3b3a8eb9SGleb Smirnoffon the backup firewall's 187*3b3a8eb9SGleb Smirnoff.Xr carp 4 188*3b3a8eb9SGleb Smirnoffvhids should be set to something higher than 189*3b3a8eb9SGleb Smirnoffthe primary's. 190*3b3a8eb9SGleb SmirnoffFor example, if firewall B is the backup, its 191*3b3a8eb9SGleb Smirnoffcarp1 configuration would look like this: 192*3b3a8eb9SGleb Smirnoffwould look like this: 193*3b3a8eb9SGleb Smirnoff.Bd -literal -offset indent 194*3b3a8eb9SGleb Smirnoffifconfig_sis1_alias0="inet 192.168.0.1/24 vhid 2 pass bar advskew 100" 195*3b3a8eb9SGleb Smirnoff.Ed 196*3b3a8eb9SGleb Smirnoff.Pp 197*3b3a8eb9SGleb SmirnoffThe following must also be added to 198*3b3a8eb9SGleb Smirnoff.Pa /etc/sysctl.conf : 199*3b3a8eb9SGleb Smirnoff.Bd -literal -offset indent 200*3b3a8eb9SGleb Smirnoffnet.inet.carp.preempt=1 201*3b3a8eb9SGleb Smirnoff.Ed 202*3b3a8eb9SGleb Smirnoff.Sh SEE ALSO 203*3b3a8eb9SGleb Smirnoff.Xr bpf 4 , 204*3b3a8eb9SGleb Smirnoff.Xr carp 4 , 205*3b3a8eb9SGleb Smirnoff.Xr enc 4 , 206*3b3a8eb9SGleb Smirnoff.Xr inet 4 , 207*3b3a8eb9SGleb Smirnoff.Xr inet6 4 , 208*3b3a8eb9SGleb Smirnoff.Xr ipsec 4 , 209*3b3a8eb9SGleb Smirnoff.Xr netintro 4 , 210*3b3a8eb9SGleb Smirnoff.Xr pf 4 , 211*3b3a8eb9SGleb Smirnoff.Xr pf.conf 5 , 212*3b3a8eb9SGleb Smirnoff.Xr protocols 5 , 213*3b3a8eb9SGleb Smirnoff.Xr rc.conf 5 , 214*3b3a8eb9SGleb Smirnoff.Xr ifconfig 8 , 215*3b3a8eb9SGleb Smirnoff.Xr tcpdump 1 216*3b3a8eb9SGleb Smirnoff.Sh HISTORY 217*3b3a8eb9SGleb SmirnoffThe 218*3b3a8eb9SGleb Smirnoff.Nm 219*3b3a8eb9SGleb Smirnoffdevice first appeared in 220*3b3a8eb9SGleb Smirnoff.Ox 3.3 . 221*3b3a8eb9SGleb SmirnoffIt was first imported to 222*3b3a8eb9SGleb Smirnoff.Fx 5.3 . 223*3b3a8eb9SGleb Smirnoff.Pp 224*3b3a8eb9SGleb SmirnoffThe 225*3b3a8eb9SGleb Smirnoff.Nm 226*3b3a8eb9SGleb Smirnoffprotocol and kernel implementation were significantly modified in 227*3b3a8eb9SGleb Smirnoff.Fx 9.0 . 228*3b3a8eb9SGleb SmirnoffThe newer protocol is not compatible with older one and will not interoperate 229*3b3a8eb9SGleb Smirnoffwith it. 230