netfilter.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick McHardy <kaber@trash.net>
To: Kurt Wampler <Kurt.Wampler@brion.com>
Cc: netfilter@vger.kernel.org
Subject: Re: How to achieve reverse NETMAP functionality?
Date: Mon, 21 Mar 2011 14:36:11 +0100	[thread overview]
Message-ID: <4D87544B.9080908@trash.net> (raw)
In-Reply-To: <20110318164554.G20495@masktools.com>

On 19.03.2011 00:45, Kurt Wampler wrote:
> We have a need to "alias" portions of a customer's internal private IP
> network, because they have an address range which overlaps a private IP
> address range used internally in one of our systems installed at their
> site.  We are trying to avoid having to re-IP either network.
> 
> We would like to define a 1:1 NAT similar to what's implemented by the
> iptables NETMAP target.  Currently, netmap can rewrite only the destination
> address during prerouting, and it can rewrite only the source address
> during postrouting.
> 
> In order to effectively alias the customer's network from the perspective
> of our host, we want to rewrite the source address of packets coming from
> the customer's network during prerouting, and rewrite the destination address
> of the corresponding return packets during postrouting -- the opposite of
> what netmap currently does.
> 
> Is there any way to achieve this by exploiting the existing configuration
> capabilities in iptables?

Its quite hard to do this properly. Basically you need to loop packets
through the stack twice (this can be done using the veth device)
and map the packets on the first round while routing from the real
device to the veth device, in the reverse direction you can route
to the veth device based on the mapped addresses. You also need to
use a different conntrack zone for the first round to make sure the
packets are not mapped back before reaching the veth device, otherwise
you can't route them properly.

      parent reply	other threads:[~2011-03-21 13:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-18 23:45 How to achieve reverse NETMAP functionality? Kurt Wampler
2011-03-19  8:20 ` Pandu Poluan
2011-03-20  8:20 ` Marek Kierdelewicz
2011-03-21 13:36 ` Patrick McHardy [this message]

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=4D87544B.9080908@trash.net \
    --to=kaber@trash.net \
    --cc=Kurt.Wampler@brion.com \
    --cc=netfilter@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).