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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem to get the IP address of user's machine

Status
Not open for further replies.

lunargirrl

Programmer
Jan 26, 2004
77
BR
Hello people,

I hope someone can help me about this.
I am having problem to read the ip address of my user's machine.
When I use REMOTE_ADDR, i am able to read the dynamic IP address that the provider gives to the user when he's connected to the internet, but I need to read the user's machine IP.

Does exist a variable that fits in my case?

TIA,
Gis.
 
Hi Lunargirrl...

The dynamic IP of the client is the actual machine's IP address. It could have a different IP on another network but on the network that client used to get to your site the IP you got from Remote_Addr is correct
 
hi logicalunatic, thanks for the quick answer.
i made a test using my machine as well.

e.G. My machine's IP is 10.0.1.69, when i connect to the internet via provider my remote_addr server variable reads the value 200.228.220.25.

Thats the funny, when I am local connected in my net, it reads the right IP number (10.0.1.69), and when i use a dial up connection (simulating an external connection) it reads the 200.228.220.25.

???

Thanks :)))
Gis.
 
Hrm,

I'm assuming you're hosting on your machine as well.

If you have Win2k or WinXP go to Network Connections in the control panel and click Advanced > Advanced Settings. There on the Adapters and Bindings tab you can change the order of the network connections in there.

Assuming you ARE hosting the page from the same machine you're dialing up with, the Remote_Addr would grab the IP at the top of that list.
 
When you connect to anything externally, (via your firewall), your WAN address is broadcasted with the packets that are sent out. This conversion is handled by the firewall.

When you connect to an internal site or application, your LAN address is broadcasted.

So, in answer to your question, there is no way to get the user's LAN address from an external site.

Hope that answers your question.

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
lunargirrl -
Like AtomicChip says, your 10.0.1.69 address is the internal address assigned by your internet router (10.x.x.x is reserved for just this purpose, as is 192.168.x.x and 172.16.x.x. See RFC-1918).

The 200.228.220.25 is the public address provided by your ISP, and is used by the router.

Most internet routers use the NAT (Network Address Translation) protocol to hide the internal network addresses from external attackers. This works not only because the router hides the internal address, but also because all routers on the internet itself are configured to block any addresses to/from the IP address ranges in RFC-1918. This is to if someone were to accidentally hook their computer (using a private address range) to the internet, it won't cause problems for others.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Correction:
Most internet routers use the NAT (Network Address Translation) protocol
Should be:
Most home and small-business routers use the NAT (Network Address Translation) protocol

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top