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: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: fushimi at rep dot fielding dot nec dot co dot jp
New email:
PHP Version: OS:

 

 [2007-07-25 07:53 UTC] fushimi at rep dot fielding dot nec dot co dot jp
Description:
------------
I am evaluating the newest PHP 5.2.3, in relation with my current PHP 5.1.2.
So, when I tried to get the remote IP using getenv(?REMOTE_ADDR?), I obtained the following results:

PHP 5.2.3 => return 0.0.0.0
PHP 5.1.2 => return 192.168.1.1

PHP in ISAPI mode.


Reproduce code:
---------------
$ip = getenv("REMOTE_ADDR");
echo "IP Address ....: ".$ip;


Expected result:
----------------
IP Address ....: 192.168.1.1

Actual result:
--------------
IP Address ....: 0.0.0.0

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 05:01:28 2024 UTC