All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pascal Hambourg <pascal.mail@plouf.fr.eu.org>
To: netfilter@lists.netfilter.org
Subject: Re: port forwarding through localhost
Date: Fri, 26 Jan 2007 23:18:57 +0100	[thread overview]
Message-ID: <45BA7E51.40505@plouf.fr.eu.org> (raw)
In-Reply-To: <000001c74194$d484d9b0$0d01a8c0@Mobi>

Hello,

Andy B. a écrit :
> 
> Webserver that uses many many mySQL connections to 127.0.0.1 (Port 3306).
> 
> Now I would like to put the mySQL server onto a dedicated machine without
> changing the "127.0.0.1" setting on a few hundred websites.
> 
> The new mySQL Server listens on 10.0.0.100:3306
> 
> My first guess was the following ruleset on the webserver:
> 
> iptables -t nat -A PREROUTING -p tcp -i lo --dport 3306 -j DNAT --to
> 10.0.0.100
> 
> Then I tried to telnet 127.0.0.1 3306, which failed immediately

Of course. Locally generated packets don't go into the PREROUTING chain.

> I figured out the prerouting is no good for localhost and changed it into:
> 
> iptables -t nat -A OUTPUT -o lo -p tcp --dport 3306 -j DNAT --to
> 10.0.0.100:3306
> 
> telnet 127.0.0.1 3306 seems to do something, but not what I expected:
> 
> $ telnet 127.0.0.1 3333

Why 3333 ?

> Trying 127.0.0.1...
> 
> <sleeping...... sleeping......>
> 
> Timeout eventually.

Does connecting directly to the SQL server work (no filtering rule that 
may block the connection) ?
What is the kernel version ? Since 2.6.11, DNAT in the OUTPUT chain does 
not mangle the source address any more. But 127.0.0.1 is an invalid 
address for external communication and is rejected by the re-routing 
decision.


  reply	other threads:[~2007-01-26 22:18 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-26 21:56 port forwarding through localhost Andy B.
2007-01-26 22:18 ` Pascal Hambourg [this message]
2007-01-26 22:29   ` Andy B.
2007-01-26 22:50     ` Pascal Hambourg
2007-01-26 22:55       ` Andy B.
2007-01-26 23:09         ` Jan Engelhardt
2007-01-30 19:54         ` Michael P. Brininstool
2007-01-31  9:09           ` Andy B.

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=45BA7E51.40505@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.