All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pascal Hambourg <pascal.mail@plouf.fr.eu.org>
To: Mail List - Netfilter <netfilter@vger.kernel.org>
Subject: Re: rule is ignored for the localhost
Date: Tue, 17 Jun 2008 16:03:47 +0200	[thread overview]
Message-ID: <4857C443.8080502@plouf.fr.eu.org> (raw)
In-Reply-To: <4856D1DB.9050107@riverviewtech.net>

Hello,

Grant Taylor a écrit :
> On 06/16/08 14:41, Artem Y. Pervin wrote:
> 
>> I want to do a simple thing. I want some port of the external 
>> interface to redirect TCP traffic to the private network.
>> So, I have the following rule sequence:
>> 
>> # Port forwarding
>> iptables -t nat -I PREROUTING -i $EXTIF -p tcp --dport 30099 -j DNAT
>> --to 192.168.10.119:22
>> iptables -t nat -I PREROUTING -i lo -p tcp --dport 30099 -j DNAT --to
>> 192.168.10.119:22
> 
> At a quick glance your rules seem to be ok.

I beg to differ. AFAIK packets routed through the loopback interface 
don't go through the nat/PREROUTING chain, so the latter rule will never 
match any packet. My understanding is that only packets creating a new 
yet unconfirmed connection go through the nat chains, and the connection 
is confirmed right after the POSTROUTING chains, before the packet is 
looped back into the PREROUTING chains. I have the feeling that 
conntrack and NAT on loopback is somehow dodgy.

So the rule must be added to the OUTPUT chain :

iptables -t nat -I OUTPUT -o lo -p tcp --dport 30099 -j DNAT --to 
192.168.10.119:22

  reply	other threads:[~2008-06-17 14:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-16 19:41 rule is ignored for the localhost Artem Y. Pervin
2008-06-16 20:49 ` Grant Taylor
2008-06-17 14:03   ` Pascal Hambourg [this message]
2008-06-17 14:16     ` Grant Taylor

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=4857C443.8080502@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 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.