From: Pascal Hambourg <pascal.mail@plouf.fr.eu.org>
To: netfilter@lists.netfilter.org
Subject: Re: DNAT doesn't work
Date: Tue, 26 Sep 2006 18:05:01 +0200 [thread overview]
Message-ID: <45194FAD.4060500@plouf.fr.eu.org> (raw)
In-Reply-To: <c936c6b70609260745r40491602uba2aef2c6ae9be34@mail.gmail.com>
Hello,
Holger Kinkelin a écrit :
>
> I'm more or less new to netfilter / iptables; so I've got a question
> about DNAT.
>
> My problem is, that my DNAT won't work. I want to reroute http-pakets
> to server X to my own server running on localhost.
>
> The first command I tried was the following:
>
> iptables -A PREROUTING -t nat -p tcp -d [IP OF X] --dport 80 \
> -j DNAT --to-destination 127.0.0.1:80
Don't DNAT connections from the outside to a loopback address. It won't
work because the input routing, which takes place right after the
PREROUTING chain, will drop packets to any destination in 127.0.0.0/8
received on any interface other than lo. So you can only reach these
destinations from the local host. Use the REDIRECT target instead, or
DNAT to the local address of the input interface.
> But: There is no effect. When I try to open a page hostet on X, the
> page loads from X, not from localhost...
>
> So I tried
>
> iptables -A PREROUTING -t nat -p tcp -d [IP OF X] --dport 80 -j REDIRECT
>
> No effect, too
If the source of the HTTP connection is the local host, you must put
this rule in the OUTPUT chain instead of PREROUTING. By the way, you can
use "DNAT --to 127.0.0.1" this time, because it's a local host
communication. Make sure trafic on the interface lo is allowed.
prev parent reply other threads:[~2006-09-26 16:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-26 14:45 DNAT doesn't work Holger Kinkelin
2006-09-26 14:59 ` Guillaume
[not found] ` <c936c6b70609260813g6389cb2br52ff21d7eb628bb2@mail.gmail.com>
2006-09-26 15:19 ` Guillaume
2006-09-26 16:05 ` Pascal Hambourg [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=45194FAD.4060500@plouf.fr.eu.org \
--to=pascal.mail@plouf.fr.eu.org \
--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.