Subject: Re: Problems with pf(4)'s rdr rules
To: None <>
From: Miles Nordin <carton@Ivy.NET>
List: current-users
Date: 11/30/2005 22:20:07
Content-Type: text/plain; charset=US-ASCII

>>>>> "dh" == Dave Huang <> writes:

    dh> rdr pass on $ext_if proto udp from any to any port 2093:2096
    dh> -> port 2093:*

try 'pfctl -s state' and see if it shows anything interesting.

Here are the rules I use for eDonkey.  UDP is different than TCP and I
found to need two rules because you never know whether your end or the
remote end is going to be the one to create the state entry.  I don't
know exactly why what you see is happening, but I think it might help
to make an extra 'nat' statement to nail down the NAT state tuple so
the outgoing packet originates from the same specific port on the PF
gateway as you are later using in the rdr rule, rather than from a
dynamic port as it will if it matches the overall NAT rule.  In this
case, if the first packet activates the nat rule first rather than
rdr, the rdr rule will never be matched by traffic coming back in, but
you will sort of experience the same effect as if it were.  dunno if
that makes sense, but consider my two rules if they make sense to you,
and try the 'pfctl -s state' or the pftop package.

rdr on $innurnet4 inet proto udp from any to $natsrc port 4672 \
        -> port 4672
nat on $innurnet4 inet proto udp from port 4672 to any -> \
        $natsrc port 4672

Content-Type: application/pgp-signature
Content-Transfer-Encoding: 7bit

Version: GnuPG v1.4.2 (NetBSD)