I set up a ipfilter config as following.
=======================================================================
pass in quick on fxp1 proto tcp from 10.0.0.0/8 to 0.0.0.0/0 port = 100 flags S keep state keep frag
map fxp0 from 10.0.0.0/8 to 0.0.0.0/0 port = 100 -> 172.31.2.199/32 portmap tcp 30000:40000 frag
=======================================================================
after pumping more than 10000 concurrent tcp connection through the ipfiltered box, I start to see packet exit on the external side of the ipfilter box without NAT. I assume there is only 10000 possible port available to MAP, once this resource was used up. Ipfilter just give up and let packets leave without nat.
Looking through the code of fr_check()
/*
* Only count/translate packets which will be passed on, out the
* interface.
*/
if (out && (pass & FR_PASS)) {
#ifdef USE_INET6
if (v == 6)
list = ipacct6[1][fr_active];
else
#endif
list = ipacct[1][fr_active];
if (list != NULL) {
u_32_t sg, sr; fin->fin_fr = list;
sg = fin->fin_group;
sr = fin->fin_rule;
if (fr_scanlist(FR_NOMATCH, ip, fin, m) & FR_ACCOUNT) {
ATOMIC_INCL(frstats[1].fr_acct);
}
fin->fin_group = sg;
fin->fin_rule = sr;
fin->fin_fr = fr;
}
changed = ip_natout(ip, fin);
} else
fin->fin_fr = fr;
RWLOCK_EXIT(&ipf_mutex);The fr_check does not care if the ip_natout() matches a MAP rule but failed to create a NAT state, causing a un-natted ip to leave the ipfilter box. Should ipfilter drop a packet if a map rule is matched but no state can be created because of other resource limit.
Regards, Ming
