pantz.org banner
Configs for firewall redundancy with CARP and pfsync on OpenBSD
Posted on 03-31-2007 02:30:00 UTC | Updated on 03-31-2007 02:30:00 UTC
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.

Reddit!

Related stories


RSS Feed RSS feed logo

About


3com

3ware

alsa

alsactl

alsamixer

amd

android

apache

areca

arm

ati

auditd

awk

badblocks

bash

bind

bios

bonnie

cable

carp

cat5

cdrom

cellphone

centos

chart

chrome

chromebook

cifs

cisco

cloudera

comcast

commands

comodo

compiz-fusion

corsair

cpufreq

cpufrequtils

cpuspeed

cron

crontab

crossover

cu

cups

cvs

database

dbus

dd

dd_rescue

ddclient

debian

decimal

dhclient

dhcp

diagnostic

diskexplorer

disks

dkim

dns

dos

dovecot

drac

dsniff

dvdauthor

e-mail

echo

editor

emerald

encryption

ethernet

expect

ext3

ext4

fat32

fedora

fetchmail

fiber

filesystems

firefox

firewall

flac

flexlm

floppy

flowtools

fonts

format

freebsd

ftp

gdm

gmail

gnome

google

gpg

greasemonkey

greylisting

growisofs

grub

hacking

hadoop

harddrive

hba

hex

hfsc

html

html5

http

https

hulu

idl

ie

ilo

intel

ios

iperf

ipmi

iptables

ipv6

irix

javascript

kde

kernel

kickstart

kmail

kprinter

krecord

kubuntu

kvm

lame

ldap

linux

logfile

lp

lpq

lpr

maradns

matlab

memory

mencoder

mhdd

mkinitrd

mkisofs

moinmoin

motherboard

mouse

movemail

mplayer

multitail

mutt

myodbc

mysql

mythtv

nagios

nameserver

netflix

netflow

nginx

nic

ntfs

ntp

nvidia

odbc

openbsd

openntpd

openoffice

openssh

openssl

openvpn

opteron

parted

partimage

patch

perl

pf

pfflowd

pfsync

photorec

php

pop3

pop3s

ports

postfix

power

procmail

proftpd

proxy

pulseaudio

putty

pxe

python

qemu

r-studio

raid

recovery

redhat

router

rpc

rsync

ruby

saltstack

samba

schedule

screen

scsi

seagate

seatools

sed

sendmail

sgi

shell

siw

smtp

snort

solaris

soundcard

sox

spam

spamd

spf

spotify

sql

sqlite

squid

srs

ssh

ssh.com

ssl

su

subnet

subversion

sudo

sun

supermicro

switches

symbols

syslinux

syslog

systemd

systemrescuecd

t1

tcpip

tcpwrappers

telnet

terminal

testdisk

tftp

thttpd

thunderbird

timezone

ting

tls

tools

tr

trac

tuning

tunnel

ubuntu

unbound

vi

vpn

wget

wiki

windows

windowsxp

wireless

wpa_supplicant

x

xauth

xfree86

xfs

xinearama

xmms

youtube

zdump

zeromq

zic

zlib