Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Bill Brelsford <wbrels@k2di.net>
To: netfilter@vger.kernel.org
Subject: NAT: re-route localhost to otherhost
Date: Mon, 23 Feb 2009 15:09:57 -0800	[thread overview]
Message-ID: <20090223230957.GA17174@k2di> (raw)

On machine host1 (10.1.1.1) I want to re-route localhost port 25
traffic to host2 (10.1.1.2).  My only nat table entries are:

 iptables -t nat -A OUTPUT -p tcp --dport 25 \
 	-j DNAT --to-destination 10.1.1.2

 iptables -t nat -A POSTROUTING -p tcp --dport 25 \
 	-j SNAT --to-source 10.1.1.1

Then "telnet host1" connects to host2 as expected (as does
"telnet host3" etc.), but "telnet localhost" hangs.  Log
statements inserted before each statement show expected results
(addresses, interfaces, etc.), except that in the localhost case
the POSTROUTING log statement is never executed; I assume SNAT is
not executed either.

The reverse translation works, i.e. changing both addresses to
127.0.0.1 results in "telnet host2" connecting to localhost.

Any explanations/fixes/suggestions?  I'm using kernel 2.6.26 and
iptables 1.4.2 (Debian lenny).

Thanks,

Bill Brelsford

                 reply	other threads:[~2009-02-23 23:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20090223230957.GA17174@k2di \
    --to=wbrels@k2di.net \
    --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