RSS feed logo RSS Feed | About Pantz.org
Configs for firewall redundancy with CARP and pfsync on OpenBSD
Posted on 03-30-2007 22:30:00 EST | Updated on 03-30-2007 22:30:00 EST
Section: /software/carp/ | Permanent Link

I setup a test of OpenBSD's CARP and PFSYNC. It went very well. Here are my notes from it.


                         wan/internet

                          +-------+
                          | host1 |
                          +-------+
                              |
                              |ne3 10.0.0.30
              ---+------------------------+---
                 |   VirtIP=10.0.0.100    |
    10.0.0.10 ne4|                        |ne4 10.0.0.20
               +-----+       172.16.0.20+-----+
               | fw1 |ne5------------ne5| fw2 |
               +-----+172.16.0.10       +-----+
 192.168.0.10 ne3|                        |ne3 192.168.0.20
                 |  VirtIP=192.168.0.100  |
              ---+------------------------+---
                              |
                              |ne3 192.168.0.30
                          +-------+
                          | host2 |
                          +-------+

                             lan


fw1 config
---------------------------------------
/etc/hostname.ne3 ->            inet 192.168.0.10 255.255.255.0 NONE
/etc/hostname.ne4 ->            inet 10.0.0.10 255.255.255.0 NONE
/etc/hostname.ne5 ->            inet 172.16.0.10 255.255.255.0 NONE
/etc/sysctl.conf  ->            net.inet.carp.preempt=1
/etc/hostname.pfsync0 ->        up syncdev ne5
/etc/hostname.carp1 ->          inet 192.168.0.100 255.255.255.0 192.168.0.255 vhid 1 carpdev ne3 pass yogi
/etc/hostname.carp2 ->          inet 10.0.0.100 255.255.255.0 10.0.0.255 vhid 2 carpdev ne4 pass booboo

fw2 config
---------------------------------------
/etc/hostname.ne3 ->            inet 192.168.0.20 255.255.255.0 NONE
/etc/hostname.ne4 ->            inet 10.0.0.20 255.255.255.0 NONE
/etc/hostname.ne5 ->            inet 172.16.0.20 255.255.255.0 NONE
/etc/sysctl.conf  ->            net.inet.carp.preempt=1
/etc/hostname.pfsync0 ->        up syncdev ne5
/etc/hostname.carp1 ->          inet 192.168.0.100 255.255.255.0 192.168.0.255 vhid 1 carpdev ne3 advskew 128 pass yogi
/etc/hostname.carp2 ->          inet 10.0.0.100 255.255.255.0 10.0.0.255 vhid 2 carpdev ne4 advskew 128 pass booboo

Other files to edit
---------------------------------------
/etc/rc.conf ->                 pf=YES,inetd=NO
/etc/sysctl.conf ->             net.inet.ip.forwarding=1
/etc/pf.conf ->                 pass quick on lo0 all
                                scrub in
                                nat on ne4 from !(ne4) to any -> (ne4:0)
                                pass quick on ne5 proto pfsync keep state (no-sync)
                                pass on { ne3, ne4 } proto carp keep state
                                pass out on ne4 proto { tcp, udp } from ne4 to any keep state
                                pass out on ne4 proto icmp all keep state

If you do this for yourself just change th interfaces names and IP's to your needs. After putting in the above configs reboot both machines. fw1 and fw2 are the firewall/routers. They nat all connections from the lan to the wan. Fw1 is the master firewall and fw2 is the secondary. The primary routes are on the carp interfaces. These are the virutal IP's that are shared between fw1 and fw2. Use pftop on both interfaces to watch your state tables to make sure everything is working ok.

Del.icio.us! | Digg Me! | Reddit!

Related stories