From: Pascal Hambourg <pascal.mail@plouf.fr.eu.org>
To: netfilter@vger.kernel.org
Subject: Re: 2 ips, same port, forward to original ip but different port
Date: Wed, 05 Nov 2008 10:42:07 +0100 [thread overview]
Message-ID: <49116A6F.1070508@plouf.fr.eu.org> (raw)
In-Reply-To: <54857.29141.qm@web45902.mail.sp1.yahoo.com>
Fu-Tung Cheng a écrit :
>
> $IPTABLES -A FORWARD -p tcp --destination-port 80 -j ACCEPT
> $IPTABLES -t nat -A PREROUTING -j REDIRECT -p tcp --destination-port
> 80 --to-ports 12080
>
> Now what I need to happen is that requests coming into ip1:80 goto
> ip1:12080 and ip2:80 goto ip2:12080. What seems to be happening is
> that all requests coming into 80 are going to ip1:12080.
If I understand correctly, you want to change only the destination port,
not the destination address. But the iptables manpage says that the
REDIRECT target replaces the destination address with the primary
address of the incoming interface, so it may not be suitable for your
purpose.
You can use the DNAT target instead. Either :
iptables -t nat -A PREROUTING -p tcp --dport 80 -j DNAT --to :12080
will translate the destination port 80 into 12080 regardless of the
destination address and without changing it,
or :
iptables -t nat -A PREROUTING -d $ip1 -p tcp --dport 80 \
-j DNAT --to $ip1:12080
iptables -t nat -A PREROUTING -d $ip2 -p tcp --dport 80 \
-j DNAT --to $ip2:12080
will translate only ip1:80 into ip1:12080 and ip2:80 into ip2:12080.
PS: What is the purpose of the first rule in the FORWARD chain ?
next prev parent reply other threads:[~2008-11-05 9:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-05 1:38 2 ips, same port, forward to original ip but different port Fu-Tung Cheng
2008-11-05 9:42 ` Pascal Hambourg [this message]
2008-11-05 18:32 ` Fu-Tung Cheng
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=49116A6F.1070508@plouf.fr.eu.org \
--to=pascal.mail@plouf.fr.eu.org \
--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