Re: Port forwarding - different results between using "127.0.0.1" and "localhost"
- From: comphelp@xxxxxxxxx (Todd H.)
- Date: 26 Feb 2007 08:41:23 -0600
"Stephan Carydakis" <scarydakis@xxxxxxxxxxxxxxxx> writes:
Hi All,
I am experiencing differing results using "ssh -R 3306:shiraz:3306
127.0.0.1" and " ssh -R 3306:shiraz:3306 localhost". If I use the IP in
port forwading, I can successfully connect to the destination MySql server
by using "localhost" or 127.0.0.1 in my connection. If I establish the port
forward using "localhost", I can only connect by using the IP address (this
is no good to me for reasons I will explain!). I've tried both the command
line mysql client and an PHP and both behave the same.
I really need to be able to use "localhost" in my connection because I have
inherited some code for a small extranet that happens to have a connection
string in about 45 different PHP files and each connection specifies
"localhost". I am trying to establish a development environment for this
extranet. I am running PHP on a Debian box but do not have a local MySql
server. I have a MySql server on Win2k machine and this is the way it must
stay. My idea is to forward local port 3306 to my Win2k's port 3306.
I do plan to fix the code so the connection string is located in just 1
file, making changes back and forth a non-issue. For now, I have to play the
hand I've been dealt. Besides, I like the idea of being able to have a
permanent forward from my Linux box to my MySql server on the Win2k machine.
I've checked that localhost resolves to 127.0.0.1. When adding the forward
using "localhost", netstat shows 127.0.0.1:3306 as listening. So is this an
SSH issue, or OS related. If it's not an SSH problem, I apologise.
I use 127.0.0.1 because some time in the past I experienced this same
problem where localhost was not reliable. I haven't seen the issue
resurface ever since.
Search and replace in 45 files, no problem:
mkdir /tmp/foo
cp *.php /tmp/foo
cd /tmp/foo
perl -pi -w -e 's/localhost/127\.0\.0\.1/g;' *.php
I didn't rigorously test this, so be sure you're working in the tmp
directory with a copy of your php code. :-)
--
Todd H.
http://www.toddh.net/
.
- Follow-Ups:
- Re: Port forwarding - different results between using "127.0.0.1" and "localhost"
- From: Stephan Carydakis
- Re: Port forwarding - different results between using "127.0.0.1" and "localhost"
- References:
- Port forwarding - different results between using "127.0.0.1" and "localhost"
- From: Stephan Carydakis
- Port forwarding - different results between using "127.0.0.1" and "localhost"
- Prev by Date: Dying SSH sessions and netgear router
- Next by Date: Re: Port forwarding - different results between using "127.0.0.1" and "localhost"
- Previous by thread: Port forwarding - different results between using "127.0.0.1" and "localhost"
- Next by thread: Re: Port forwarding - different results between using "127.0.0.1" and "localhost"
- Index(es):
Relevant Pages
|
|