diff --git a/sys/contrib/ipfilter/netinet/ip_nat.c b/sys/contrib/ipfilter/netinet/ip_nat.c index 8b227e0b4b2b..d6f0b55a187a 100644 --- a/sys/contrib/ipfilter/netinet/ip_nat.c +++ b/sys/contrib/ipfilter/netinet/ip_nat.c @@ -2033,11 +2033,13 @@ natinfo_t *ni; * Standard port translation. Select next port. */ if (np->in_flags & IPN_SEQUENTIAL) { - port = htons(np->in_pnext); + port = np->in_pnext; } else { port = ipf_random() % (ntohs(np->in_pmax) - ntohs(np->in_pmin)); + port += ntohs(np->in_pmin); } + port = htons(port); np->in_pnext++; if (np->in_pnext > ntohs(np->in_pmax)) {