search
Japanese Chinese Nederlands Espanol Italiano Deutsch Francais Twitter Rss Feeds
IIS GroupsView
Frontpage Client
Frontpage Extensions Windowsnt
Frontpage Programming
Inetserver Asp Db
Inetserver Asp General
Inetserver Iis
Inetserver Iis Security

Group SummariesView
.NET Framework
Access
BizTalk
Certifications
CRM
DDK
Exchange Server
FoxPro
French
French .NET
Games
German
German .NET
Graphic Design
IIS
Internet
ISA Server
Italian
Italian .NET
Maps
MCIS
Miscellaneous
Mobile Application Development
Money
MSN
Networking
Office
Ops Mgr
Publisher
Security
SharePoint
Small Business
Spanish
Spanish .NET
SQL Server
Systems Management Server
Transaction Server
Virtual PC / Virtual Server
Visual Studio
Win32
Windows 2000
Windows 2003 Server
Windows 7
Windows Live
Windows Media
Windows Update
Windows Vista
Windows XP
 

View All Microsoft Inetserver Iis Posts  Ask A New Question 

REMOTE_ADDR Gives my External IP Instead of LAN Address - danknau

Tuesday, February 13, 2007 11:45 AM

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?
reply
 

When you say "Access this server by domain name" what exactly do you mean? - Ken Schaefer

Tuesday, February 13, 2007 4:14 PM

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
reply

No, you misunderstand REMOTE_ADDR. - David Wang

Wednesday, February 14, 2007 7:11 AM

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
//
reply
 
 

Previous Microsoft Inetserver Iis conversation.