Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Mart Frauenlob <mart.frauenlob@chello.at>
To: netfilter@vger.kernel.org
Subject: Re: Mapping external to internal IP addresses
Date: Thu, 24 Dec 2009 11:01:25 +0100	[thread overview]
Message-ID: <4B333BF5.8030005@chello.at> (raw)
In-Reply-To: <4B32803B.1010202@plouf.fr.eu.org>

On 23.12.2009 21:40, Pascal Hambourg wrote:
> Hello,
> 
> Mart Frauenlob a écrit :
>>
>> Nick Peirson wrote:
>>>
>>> We've got a couple of servers with external IP addresses NAT'd to internal
>>> IP addresses. Unfortunately the firewall that's performing the NAT isn't
>>> under our control and we have a problem where the servers can't access each
>>> other via their external IPs.
> 
> This is a common problem.
> 
>>> This causes a problem when we use domain names
>>> on the servers, as the DNS lookup returns the external IP address. Ideally
>>> I'd like to avoid maintaing hosts files or an internal DNS server.
>>>
>>> I looked to solve this with a iptables rule on each of the servers as
>>> follows:
>>> iptables -t mangle -A PREROUTING -d 1.1.1.32/29 -j NETMAP --to 2.2.2.32/29
>>>
>>> where 1.1.1.32/29 is the range of external IPs and 2.2.2.32/29 is the range
>>> of internal IPs.
> 
> Note : the range 192.0.2.0/24 is available and reserved for examples and
> documentation. Feel free to use is instead of addresses allocated to
> someone else.
> 
>>> I was expecting this to map the IP address from the
>>> external to the internal IP.
> 
> Assuming that 1.1.1.32+n maps to 2.2.2.32+n.
> 
>>> Firstly, I'm not sure if this would work at all, and if I'm heading in
>>> completely the wrong direction and someone has a better solution, I'd be
>>> happy to hear it.
> 
> Can't you just assign the external addresses to the servers as secondary
> addresses ?
> 
>>> Secondly, if I've got the right idea my implementation is a little wrong.
>>> When I run the command, I get "iptables: Invalid argument", which doesn't
>>> provide much info, and I'm not sure how to go about debugging.
>>
>> wrong table, should be the nat table.
> 
> Wrong chain too. This is locally generated traffic, so the right chain
> is OUTPUT, not PREROUTING.


Oh, yes I was wrong :/ Don't know why I messed up. sorry for the noise.

      reply	other threads:[~2009-12-24 10:01 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-23 15:16 Mapping external to internal IP addresses Nick Peirson
2009-12-23 15:52 ` Mart Frauenlob
2009-12-23 20:40   ` Pascal Hambourg
2009-12-24 10:01     ` Mart Frauenlob [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=4B333BF5.8030005@chello.at \
    --to=mart.frauenlob@chello.at \
    --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