 |
REMOTE_ADDR Gives my External IP Instead of LAN Address - danknau |
13-Feb-07 11:45:28
|
I have a webserver which is behaving strangely. The server is a
fresh
copy of Windows 2003 running IIS with default options + Active Server
Pages installed. The server is connected to a Linksys router, and
has
a static IP address of 192.168.1.10.
When I access a page with the following script directly from the
server, my WAN IP address is returned (24.x.x.x.), instead of my LAN
address.
Dim sIPAddress
sIPAddress = Request.ServerVariables("REMOTE_ADDR")
Response.Write "<h1>IP Address = <b>" & sIPAddress & "</b></h1>"
%>
Everything I've read about the REMOTE_ADDR server variable tells me
that it should return the IP address of the machine accessing the
page. Shouldn't this return the 192 address?
When I view the page as //localhost/dev/ip.asp, it returns the 127.
address, but when I view the page using my domain name, it returns
the
external IP.
Any suggestions? |
 |
| |
| |
|
| |
|
REMOTE_ADDR Gives my External IP Instead of LAN Address - Ken Schaefer |
13-Feb-07 04:14:12
|
When you say "Access this server by domain name" what exactly do you mean?
If you have a publicly resolvable FQDN that points to your external IP
address, then your requests will go out to the external interface of your
NAT router. The NAT router then port forwards the requests to your internal
host. It may be that your Linksys box does something fancy to the packets
(subsituting the external IP as the source IP) because it shouldn't be
routing packets from your internal network into your network from the
external interface...
Cheers
Ken |
 |
| |
REMOTE_ADDR Gives my External IP Instead of LAN Address - David Wang |
14-Feb-07 07:11:40
|
No, you misunderstand REMOTE_ADDR. It does not return the "IP address
of the machine accessing the page".
It returns the source IP of the network packet which originated from
the client which actually reaches the server. That source IP depends
on how the network packet gets routed to your server.
My advice is that whatever REMOTE_ADDR returns is what you get, so if
you don't like the value, you have to change your networking to make
it route the way you want. Read what Ken has said.
//David
http://w3-4u.blogspot.com
http://blogs.msdn.com/David.Wang
// |
 |
| |
|
|
| IIS WebServices (XML/SOAP) |