Hello all,
I have set up a load-balancing PF (on a NetBSD kame box, but that
hopefully won't affect anything) and have two IP I'm redirecting
ports from. The first connection is a T1 and the second is an un-
related DSL.
Internal:
sip0: LAN 192.168.0.1/24
External:
sip1: WAN 123.123.123.123/32, gw: 123.123.123.1 (T1)
sip2: WAN 234.234.234.234/32, gw: 234.234.234.1 (DSL)
I have our domain name pointing at the T1's IP, and I would like my
computers on the local subnet to be able to connect to the external
ports on the domain name (so when I take a laptop home, I don't have
to change imap servers, etc.) things are fine when pf redirects me
out the T1's outbound connection, but very frequently it will redirect
me out the DSL's connection, and it times out while trying to reach
the T1's IP.
I've tried things like:
# route packets from any IPs on $ext_if1 to $ext_gw1 and the same for
# $ext_if2 and $ext_gw2
pass out on $ext_if1 route-to ($ext_if2 $ext_gw2) from $ext_if2 to any
pass out on $ext_if2 route-to ($ext_if1 $ext_gw1) from $ext_if1 to any
but that didn't appear to work.
one thing I have noticed is that traceroutes appear to totally by-pass
the pf machine, the first hop I see is either 123.123.123.1 or
234.234.234.1
Any ideas on how to fix this?
Thanks!
Jonathan
pf.conf file:
lan_net = "192.168.0.0/24"
int_if = "sip0"
ext_if1 = "sip1"
ext_if2 = "sip2"
ext_gw1 = "123.123.123.1"
ext_gw2 = "234.234.234.1"
webserver = "192.168.0.2"
emailserver = "192.168.0.2"
scrub in all
rdr on { $ext_if1, $ext_if2} proto tcp from any to any port 80 -> $webserver
rdr on { $ext_if1, $ext_if2} proto tcp from any to any port 143 -> $emailserver
# nat outgoing connections on each internet interface
nat on $ext_if1 from $lan_net to any -> ($ext_if1)
nat on $ext_if2 from $lan_net to any -> ($ext_if2)
block in log from any to any
block out log from any to any
pass in on { $ext_if1, $ext_if2} proto tcp from any to $webserver port 80
pass in on { $ext_if1, $ext_if2} proto tcp from any to $emailserver port 143
# route packets from any IPs on $ext_if1 to $ext_gw1 and the same for
# $ext_if2 and $ext_gw2
pass out log on $ext_if1 route-to ($ext_if2 $ext_gw2) from $ext_if2 to any
pass out log on $ext_if2 route-to ($ext_if1 $ext_gw1) from $ext_if1 to any
# pass all outgoing packets on internal interface
pass out on $int_if from any to $lan_net
# pass in quick any packets destined for the gateway itself
pass in quick on $int_if from $lan_net to $int_if
# load balance outgoing tcp traffic from internal network.
pass in on $int_if route-to \
{ ($ext_if1 $ext_gw1), ($ext_if2 $ext_gw2) } round-robin \
proto tcp from $lan_net to any
# load balance outgoing udp and icmp traffic from internal network
pass in on $int_if route-to \
{ ($ext_if1 $ext_gw1), ($ext_if2 $ext_gw2) } round-robin \
proto { udp, icmp } from $lan_net to any keep state
# general "pass out" rules for external interfaces
pass out on $ext_if1 proto tcp from any to any flags S/SA modulate state
pass out on $ext_if1 proto { udp, icmp } from any to any keep state
pass out on $ext_if2 proto tcp from any to any flags S/SA modulate state
pass out on $ext_if2 proto { udp, icmp } from any to any keep state