All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philip Craig <philipc@snapgear.com>
To: Jesse Gordon <jesseg@nikola.com>
Cc: netfilter@lists.netfilter.org
Subject: Re: Unmatchable packet?
Date: Fri, 25 Nov 2005 11:11:18 +1000	[thread overview]
Message-ID: <438664B6.2090807@snapgear.com> (raw)
In-Reply-To: <002201c5f0ec$ef3f2c50$5e00800a@printserver>

On 11/24/2005 09:48 PM, Jesse Gordon wrote:
> I ran across a new word (new only to me) 'Fast-nat' -- seems some kernels --  
> at least 2.2 kernels -- had some fast simple dumb stateless natting 
> capabilities in them.
> I wonder if that's what I should be looking into.

The custom mangle target that I referred to would have the same
function as fast-nat (although it wouldn't be as fast ;-)
2.4 also has fast-nat, but I couldn't see it in 2.6.

> I need to rewrite the address so the calling party gets replies with the 
> correct source address.
> I've very carefully created a .PNG diagram on this webpage including IPs and 
> text descriptions here:
> http://jesseg.nikola.com:8080/asym-nat-route/
> This will explain Exactly what I'm trying to do, and why I need to snat on 
> the connection replies.

Okay I can see what you are doing here, and it isn't going to
work with standard iptables NAT.  Assymetrical routing and NAT
are incompatible.

Even your "working" case is not ideal, each direction is seeing
only half the packets and so they can't keep state fully.  Anything
that requires a NAT helper will fail.  eg FTP data connections

> It seems iptables has no problem matching and SNATting reply packets as long 
> as they aren't the reply packets generated
> by a local server.

No.  It has no problem matching and SNATing replies as long
as they are the first packet of the connection that it sees.

> In other words, when a connection is initiated by the Workstation, not only 
> is the first nat rule natting the first request packet,
> the second nat rule is also matching and natting the reply packet. Same 
> thing with the incoming connection.
> 
> But shouldn't the reply packet be ignored by all nat rules, since nat only 
> sees first packet of connection?

See Robert's explanation.
Also, try doing 'iptables -t nat -L -nv' and look at the packet
counts on the rules to see exactly which are matching.

> But I can't nat in any table other then nat, right?

Correct.

>>The mangle table also sees every packet.  It would be possible to write
>>a custom target for use in the mangle table that changes the source
>>address as you desire.  However, noone has written such a target as
>>far as I know.
>>
> 
> 
> 'Custom target' = a module or some addition to the source code, right?

Yes.

> Also, is my current understanding that "There are some packets which simply 
> cannot be source natted," correct?

Incorrect.  The source natting is determined by the first packet
in the connection.   You cannot *change* this source natting for
subsequent packets.

> It may be that if I knew how to use the 'ip' program, I could do everything 
> I need with 'ip route' and so on. I'm certainly open to suggestions.

Yes.  You can use CONNMARK to mark connections that are initially
received on the internal interface, and then use 'ip rule' and 'ip route'
to route those packets back out the internal interface to the
Box A, which will use its existing NAT mapping to correctly source
NAT them automatically (ie no further NAT rules required).


  parent reply	other threads:[~2005-11-25  1:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-22 20:58 Unmatchable packet? Jesse Gordon
2005-11-22 21:28 ` Jesse Gordon
2005-11-23  0:46   ` Nikolai Georgiev
2005-11-23  1:46     ` Jesse Gordon
2005-11-23  6:05       ` Philip Craig
2005-11-23  7:03         ` Jesse Gordon
2005-11-23  7:19           ` Philip Craig
2005-11-24 11:48             ` Jesse Gordon
2005-11-24 14:29               ` Robert Nichols
2005-11-25  1:11               ` Philip Craig [this message]
2005-11-28 19:11                 ` Jesse Gordon

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=438664B6.2090807@snapgear.com \
    --to=philipc@snapgear.com \
    --cc=jesseg@nikola.com \
    --cc=netfilter@lists.netfilter.org \
    /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.