From: Michael Shuey <shuey@fmepnet.org>
To: Harald Welte <laforge@gnumonks.org>, netfilter-devel@lists.samba.org
Subject: Re: NAT and locally bound sockets
Date: Mon, 1 Jul 2002 11:32:32 -0500 [thread overview]
Message-ID: <20020701163232.GB7090@lucky> (raw)
In-Reply-To: <20020530153247.I7658@sunbeam.de.gnumonks.org>
On Thu, May 30, 2002 at 03:32:47PM +0200, Harald Welte wrote:
> Interestingly I don't remember this bug. I (and nobody else) has added
> something to the TODO list about this either. Maybe it somehow got lost :(
I can't fault that; heck, I just took a month to reply to this email.
I looked up the previous comment about this issue:
http://lists.samba.org/pipermail/netfilter-devel/2002-January/003041.html
> Are you aware thet netfilter/iptables NAT is [in IETF terms] 'symmetric nat',
> which means that we can use the same port on the NAT gw multiple times, as
> long as the tuple (consisting out of srcip,dstip,srcport,dstport,l4proto) is
> unique.
Yes, I am aware that netfilter provides symmetric nat. Unfortunately, its
port selection can provide a tuple that is _not_ unique.
> Could you please try to describe the scenario of this alleged bug?
I ran into this when I had 100 hosts behind a single NAT box, all trying to
reach the same NFS file server at the same time the NAT box itself was
mounting the NFS server. At the time I was using the default SNAT options
(not specifying a port range for the translations) so any traffic originating
at a port below 1024 would be mapped to natbox:<something under 1024>. That
was working as expected.
In this scenario, think about the tuple for a moment. Since all clients and
the natbox are mounting the same NFS server, selecting the same port by
default, using UDP across the board, the connection tuples are (after SNAT)
going to be very similar - they only differ in srcport. Normally that would
be just fine; however, with a high level of traffic the NAT system would
occaisionally select a srcport that was already in use by the NFS client local
to natbox. That's not fine - it causes quite a few NFS timeouts, retransmits,
etc. on natbox.
This is hard to observe (unless you have lots of NAT clients or a very
restricted range of possible srcports for translations), but lsof on the
natbox and a packet sniffer showed that this was, in fact, occurring. I
ended up setting up an IP alias on the natbox just to route all translated
traffic through. When I did that everything worked normally again - no NFS
problems at all on natbox (which is to be expected, since the translated
connections' tuples are now different from the local NFS client).
To fix this the NAT code needs to check to see what, if any, ports are
locally bound (and not use them, of course!) The original poster for this
bug had a bit of code that tried to address this, but it was limited to UDP.
A proper fix would have to involve TCP as well (as a similar problem most
likely exists there, it just crops up much less frequently).
--
Mike Shuey
next parent reply other threads:[~2002-07-01 16:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20020529164926.GA9003@gort.ecn.purdue.edu>
[not found] ` <20020530153247.I7658@sunbeam.de.gnumonks.org>
2002-07-01 16:32 ` Michael Shuey [this message]
2002-07-01 16:59 ` NAT and locally bound sockets Henrik Nordstrom
2002-07-01 18:46 ` Michael Shuey
2002-07-02 7:52 ` Henrik Nordstrom
2002-07-02 14:21 ` Harald Welte
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020701163232.GB7090@lucky \
--to=shuey@fmepnet.org \
--cc=laforge@gnumonks.org \
--cc=netfilter-devel@lists.samba.org \
--cc=shuey@purdue.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.