php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #42094 getenv("REMOTE_ADDR") returns no IP address
Submitted: 2007-07-25 07:53 UTC Modified: 2007-07-27 04:59 UTC
From: fushimi at rep dot fielding dot nec dot co dot jp Assigned:
Status: Not a bug Package: Apache2 related
PHP Version: 5.2.3 OS: Windows 2000
Private report: No CVE-ID:
 [2007-07-25 07:53 UTC] fushimi at rep dot fielding dot nec dot co dot jp

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-07-25 11:58 UTC] jani@php.net
Does it show up in $_SERVER['REMOTE_ADDR'] ??
 [2007-07-26 00:48 UTC] fushimi at rep dot fielding dot nec dot co dot jp
Thank you, to reply me so quickly.

Yes, $_SERVER['REMOTE_ADDR'] return the right IP address.

One more thing that I forgot to mention, my Http server is Apache version 2.2.4.

To help you, below is the results of PHP variable using phpinfo():
PHP5.2.3 and Apache2.2.4
========================
_SERVER["SERVER_ADDR"] 192.168.1.3 
_SERVER["SERVER_PORT"] 80 
_SERVER["REMOTE_ADDR"] 0.0.0.0
_SERVER["REMOTE_PORT"] 0

PHP5.1.2 and Apache2.0.59
=========================
_SERVER["SERVER_ADDR"] 192.168.1.2 
_SERVER["SERVER_PORT"] 80 
_SERVER["REMOTE_ADDR"] 192.168.1.1 
_SERVER["REMOTE_PORT"] 2476
 [2007-07-26 09:50 UTC] jani@php.net
It's apache that isn't setting it. PHP only sets the variables to whatever the server says they are. No bug in PHP.
 [2007-07-27 04:59 UTC] fushimi at rep dot fielding dot nec dot co dot jp
Thank you again for your help.

Could you give me any idea about how can I enable this option in Apache2?
 [2012-03-21 15:19 UTC] aladdin18 at hotmail dot com
Hi every one my name is AlAa

My problem with $_SERVER['remote_addr']

I'm not sure if I'm having a problem with the installation of PHP on the server or if there's something that I'm not doing right in the code, but I am trying to capture the IP address of anyone that is trying to log into a secure part of a site. Regardless of my IP address, when I do:

Code:

echo $_SERVER['remote_addr'];

It returns '192.168.1.1'. This is the first time I've written code that is being used on a Windows Server, so I don't know if that has anything to do with it.

I've run phpinfo(), and in the PHP Variables section, it shows "_SERVER["REMOTE_ADDR"]" : 192.168.1.1. Does this mean that the php.ini file is setup wrong, or am I missing something?

i am running my own server on windows 7 iis7.5 with php as fastcgi and i am behind a router with a dynamic ip not static and i am using 
http://www.no-ip.com/ that give me a link to my router and i am opening 80 port in my router forwarding it to my id address 192.168.1.5 and i have tested a php file that contains 
<?php
echo $_SERVER['REMOTE_ADDR'];
?>
tested it using tor network that give me ip out of my network to test that file always give me the same result 192.168.1.1 i am trying to get IP address of the visitor and i asked someone of my friends to use this form it sends the same ip

i hope someone tells me what i am doing wrong and the solution for this problem

Thanks in advance
 
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Thu Jun 11 11:46:17 2015 UTC