Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Joel Newkirk <netfilter@newkirk.us>
To: Henry Ritzlmayr <h.ritzlmayr@gmx.at>, netfilter@lists.netfilter.org
Subject: Re: Masquerading on local ports
Date: Fri, 21 Mar 2003 02:22:47 -0500	[thread overview]
Message-ID: <200303210222.47189.netfilter@newkirk.us> (raw)
In-Reply-To: <1048169013.1491.107.camel@localhost.localdomain>

On Thursday 20 March 2003 09:03 am, Henry Ritzlmayr wrote:
> Hi everyone - this is my first post to this list - so if anything is
> wrong with my way of posting please tell.
>
> And here is the question. How is it possible to nat a lokal port?
>
> IPTABLES -t nat -A PREROUTING -p tcp -d 127.0.0.1 --destination-port
> 81 -j DNAT --to-destination 127.0.0.1:80
>
> telnet localhost 80  <<< works
> telnet localhost 81  <<< Connection refused
>
> Henry

Packets originating on the local box never go through the PREROUTING 
chains.  This is why there is an OUTPUT chain in the nat table.  (and 
the mangle table)

iptables -t nat -A OUTPUT -o lo -p tcp --dport 81 -j DNAT --to 
127.0.0.1:80

should do it.  I'm not sure if the REDIRECT target would work properly 
for this use (localhost->localhost), but you can try easily enough.

j


  parent reply	other threads:[~2003-03-21  7:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-03-20 14:03 Masquerading on local ports Henry Ritzlmayr
2003-03-20 15:29 ` Rob Sterenborg
2003-03-20 16:14   ` henry ritzlmayr
2003-03-20 16:26   ` Henry Ritzlmayr
2003-03-20 18:34     ` alexb
2003-03-21  7:22 ` Joel Newkirk [this message]
2003-03-21 17:17   ` Henry Ritzlmayr

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=200303210222.47189.netfilter@newkirk.us \
    --to=netfilter@newkirk.us \
    --cc=h.ritzlmayr@gmx.at \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox