Linux Netfilter discussions
 help / color / mirror / Atom feed
From: Jason Opperisano <opie@817west.com>
To: netfilter@lists.netfilter.org
Subject: Re: redirect to 127.0.0.1 [corrected]
Date: Tue, 17 May 2005 15:15:20 -0400	[thread overview]
Message-ID: <20050517191520.GA2038@bender.817west.com> (raw)
In-Reply-To: <BAY16-F138F014D31905BBA75CC46BA160@phx.gbl>

On Tue, May 17, 2005 at 05:04:30PM +0000, bagwan ali wrote:
> Hi All,
> 
> I have a problem redirecting traffic from $SERVER:11000 to 127.0.0.1:10001. 
> The situation is that I need more than one serverprocess listening to ONE 
> specific port in this case port 11000. Ofcourse this is  not possible, but 
> there is only ONE client connection at a time to ONE serverprocess. So 
> instead that the process is listening on $SERVER:11000, it is listening on 
> 127.0.0.1:10001 and the second serverprocess is listening on 
> 127.0.0.1:10002 and so on. So I can depending on the source IP address 
> redirect traffic from $SERVER:11000 to 127.0.0.1:$FREEPORT. Let me give an 
> example in pseudo firewall rules:

is it a new quarter already?

1) REDIRECT does not rewrite the dst IP to be 127.0.0.1, it rewrites the 
   dst IP to be IP of the inbound interface.  this is *not*
   configurable.
   
2) DNAT allows you to configure the IP address that the dst IP will be 
   re-written to; however, a DNAT --to 127.0.0.1 will *not* work, as the 
   packet will be dropped by the linux kernel's martian routing code 
   (packets destined for 127/8 must not be received "on the wire.")
   
3) since it's been a quarter or so since someone's asked this, i just 
   had an idea--this comes with no guarantee or warranty express nor
   implied:

   # change the input interface on packets to be DNAT-ed to 127.0.0.1
   # to be the loopback interface
   iptables -t mangle -A PREROUTING -p tcp -s $CLIENT_ONE \ 
     -d $SERVER --dport 11000 -j ROUTE --iif lo --continue
     
   # DNAT packets to 127.0.0.1
   iptables -t nat -A PREROUTING -p tcp -s $CLIENT_ONE \ 
     -d $SERVER --dport 11000 -j DNAT --to 127.0.0.1:11001

i don't even know if the above rules will apply, much less work.

-j

--
"Lois: Peter, you're drunk again.
 Peter: No, I'm just exhausted because I've been up all night drinking."
        --Family Guy


      parent reply	other threads:[~2005-05-17 19:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-17 17:04 redirect to 127.0.0.1 [corrected] bagwan ali
2005-05-17 18:57 ` Taylor, Grant
2005-05-17 20:06   ` Taylor, Grant
2005-05-17 20:32     ` Jason Opperisano
2005-05-17 21:46       ` Taylor, Grant
2005-05-17 21:48       ` Taylor, Grant
2005-05-17 19:15 ` Jason Opperisano [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=20050517191520.GA2038@bender.817west.com \
    --to=opie@817west.com \
    --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