i've got a freebsd 4.7 box configured to do nat for our isp's dsl
customers.  the nat setup was previously running on a cisco 3640 but the
router couldn't handle the load.  now the router is connected to the
freebsd box with a crossover cable, and the box has another ethernet card
connecting it to the lan.  for the most part this works great.  under
normal usage the box has 3000-4000 nat table entries.  however sometimes a
customer will generate a large number of entries.  we have one customer
who uses a p2p scanner that generates over 58000 nat table entries.  once
the nat table size exceeds 60000 ipnat seems to break.  existing
connections still work but new connections fail.  it also takes a long
time to execute any commands from the command line.  once i'm able to
execute ipnat -F the system works again.  i read the faq and checked the
email archives and put

#define LARGE_NAT

in ip_nat.h, recompiled and reinstalled ipfilter as well as a new kernel.
ipnat still stops working once the nat table gets much above 60000
entries, although the command line is more responsive (takes about 20
seconds to execute a command instead of 5 to 10 minutes).  here are the
relevant entries from my kernel config file:

maxusers        128
options         IPFILTER                #ipfilter support
options         IPFILTER_LOG            #ipfilter logging
options         NMBCLUSTERS=8192
options         NMBUFS=65536

the machine has 16 ip addresses aliased to it just for nat usage, along
with several other ips.  here is my ipnat rules file:

map fxp1 172.31.0.0/16 -> 63.162.213.176/28 proxy port ftp ftp/tcp
map fxp1 172.31.0.0/16 -> 63.162.213.176/28 portmap tcp/udp auto
map fxp1 172.31.0.0/16 -> 63.162.213.176/28
map fxp1 192.168.254.0/24 -> 63.162.213.176/28 proxy port ftp ftp/tcp
map fxp1 192.168.254.0/24 -> 63.162.213.176/28 portmap tcp/udp auto
map fxp1 192.168.254.0/24 -> 63.162.213.176/28
map fxp1 192.168.253.0/24 -> 63.162.213.176/28 proxy port ftp ftp/tcp
map fxp1 192.168.253.0/24 -> 63.162.213.176/28 portmap tcp/udp auto
map fxp1 192.168.253.0/24 -> 63.162.213.176/28

our dsl customers use the 172.31 ips.  the router uses 192.168.254 for
itself, and is connected to fxp0.  there's also a third ethernet card used
for in-building customers with a direct lan connection, they are currently
being assigned 192.168.253 ips via dhcp.  the machine is a pentium 200
with 96M of memory.  i'd appreciate any hints as to why the nat setup
breaks around 60000 rules, the 16 nat ip addresses should provide enough
ip/port pairs for several hundred thousand nat table entries.  do i need
to change the size of the state table in ip_state.h as well as increasing
the nat table size?  what else can i look at to see why this setup isn't
scaling up?

- Mike



Reply via email to