Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Show internal IP at Proxy connection 1

Status
Not open for further replies.

paispatin

Technical User
Oct 21, 2003
62
A1
Dear all,

Using $REMOTE_ADDR will get the remote IP.
If the remote IP using proxy server, than the $REMOTE_ADDR will be show the proxy IP.

Can I see the computer remote IP inside that proxy sever with PHP script?

the case :
computer a [192.168.0.51] -> proxy server [201.32.25.107]

If using $REMOTE_ADDR, the output will be 201.32.25.107, can I see the 192.168.0.51 address using a function at PHP rather than using $REMOTE_ADDR?

Thank you in advance.
 
Use Env variable

$_SERVER['HTTP_X_FORWARDED_FOR']


--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Still not work.

Code:
$a=$REMOTE_ADDR;
$b=$_SERVER['HTTP_X_FORWARDED_FOR'];

echo "Testing show Remote IP : ".$a." - ".$b;
 
paidpatin:
You can get the original client's IP address only if the proxy reports it. Many proxies do not.

Even if the proxy server does report the client IP, that value is not guaranteed to be unique. Your own example client IP, 192.168.0.51, is a non-routeable address and can be reused in multiple networks. Addresses beginning with "10.", "192.168." and "172.16." all fall into this category.

Multiple proxy servers could report the same client address, even if those two identical client addresses do not refer to the same physical machines.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Sleipnir214, thank you for your answer.

That's mean if I use non private IP such as 201.*.*.* the proxy will give us report with $_SERVER['HTTP_X_FORWARDED_FOR'] function (of course if the proxy report it)?

Thank's

 
If the address the proxy server gleans from the connection from the client is a routable address, and if that proxy server reports the address to your server, then I'm not sure the address can be trusted to be unique then, either.

There could be some kind of dynamic network address translation somewhere which could also have more than one user being reported at a single address.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Thank you for your reply.

One of my friend ever told me that he could catch all IP who come to his website even the visitor behind proxy server using PHP, but he don't want to tell me how to do it. That's why I ask for expert here :)

So, I it mean he (my friend) not always could catch all visitor IP, right?

Thank you.
 
He can catch user addresses reported by proxy servers and he can catch the IP addresses of the proxies themselves.

But he can't catch what isn't reported and he can't necessarily deterministically relate a client IP address to a particular user.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
sleipnir214
Excellent explanation.
A star for you.




--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Not sure that's all true. does a good job of getting the NATted IP address; although it uses some "Active Scripting" that I can't find documentation for. The JS is encoded on the page, but I've tried the firewall tests and on some machines it works, others it doesn't, but I was quite suprised to see the internal IP's on some machines.

-Tim
 
Maybe a weird idea,
but does vb and therefore ASP and maybe even Java give you possibilities to execute programs on a user's machine?

If so, what stops you from running something like ipconfig to get the local ip or even scan the registry (just saw someone posted an article about reading the registry...



JR
As a wise man once said: To build the house you need the stone.
Back to the Basics!
 
PHP/ASP are server-side languages, therefor they can't read anything from the client's registry, neither can they execute stuff in the client's pc.

That post you read about reading the registry is to read the server's registry (the machine running PHP, not the machine accessing the website).

jamesp0tter,
jamespotter@netcabo.pt

p.s.: sorry for my (sometimes) bad english :p
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top