Print Page | Close Window

Request.ServerVariables("remote_addr")

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=8403
Printed Date: 28 March 2026 at 11:59pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Request.ServerVariables("remote_addr")
Posted By: Dmitry
Subject: Request.ServerVariables("remote_addr")
Date Posted: 29 December 2003 at 1:14pm

I try to use script to get client IP

<%
dim IPAddr
IPAddr = Request.ServerVariables("remote_addr")
Response.Write("Your IP Address is " & IPAddr)
%>

but script return IP of Web site, not CLIENT and not null value!

My site is hosted on W2000 server SP3, IIS, ISA


 




Replies:
Posted By: dpyers
Date Posted: 29 December 2003 at 2:02pm

Request.ServerVariables("Remote_Addr")

...works for me. Shows my local ip when run from a script on the server



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: MorningZ
Date Posted: 29 December 2003 at 9:41pm

Request.ServerVariables("REMOTE_HOST")

will always return whatever requested it's IP address



-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: Dmitry
Date Posted: 05 January 2004 at 7:11am

Always?

Try this one:

http://m-200.ru/remote_addr/remote_addr.asp - http://m-200.ru/remote_addr/remote_addr.asp

<%
dim IAddr
IPAddr = Request.ServerVariables("remote_addr")
Response.Write("Request.ServerVariables(&quot;remote_add r&quot;) :" & IPAddr)
%>
<br>
<%
dim RH
RH = Request.ServerVariables("REMOTE_HOST")

Response.Write("Request.ServerVariables(&quot;REMOTE_HOS T&quot;) :" & RH)
%>



Posted By: dpyers
Date Posted: 05 January 2004 at 11:13am
While remote_addr can be used for ip spoofing, remote_host  can be configured in the server to be a reverse-dns lookup.

-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: MorningZ
Date Posted: 06 January 2004 at 12:52pm
Originally posted by Dmitry Dmitry wrote:

Always?

Try this one:

http://m-200.ru/remote_addr/remote_addr.asp - http://m-200.ru/remote_addr/remote_addr.asp

<%
dim IAddr
IPAddr = Request.ServerVariables("remote_addr")
Response.Write("Request.ServerVariables(&quot;remote_add r&quot;) :" & IPAddr)
%>
<br>
<%
dim RH
RH = Request.ServerVariables("REMOTE_HOST")

Response.Write("Request.ServerVariables(&quot;REMOTE_HOS T&quot;) :" & RH)
%>


not sure what didn't work for you, but that link works fine for me, shows my IP with no probs

-------------
Contribute to the working anarchy we fondly call the Internet


Posted By: dpyers
Date Posted: 06 January 2004 at 1:24pm

REMOTE_HOST in Dimitry's example link returns "m-200.ru" for me. It's a server configuration on his end. Your server is not set-up to return the reverse dns string, but quite a few are.

If I cut and paste his code into a file on my server, it returns the ip.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Dmitry
Date Posted: 13 January 2004 at 7:58am

If server is not configured to return the reverse dns

(you mean :

\Inetpub\AdminScripts>cscript adsutil.vbs set /w3svc/EnableReverseDNS false

Microsoft (R) Windows Script Host Version 5.6

Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

EnableReverseDNS                  : (BOOLEAN) Flase

)

It return "IP addres" on Request.ServerVariables("REMOTE_HOST")

same as "REMOTE_ADDR" in my case server IPaddres

if  I set "EnableReverseDNS true"

\Inetpub\AdminScripts>cscript adsutil.vbs set /w3svc/EnableReverseDNS true

EnableReverseDNS                  : (BOOLEAN) True

it return "m-200.ru" on Request.ServerVariables("REMOTE_HOST") 

Do you know other way to configure server to return the reverse dns?



Posted By: dpyers
Date Posted: 13 January 2004 at 9:47am

That's how it's done. Try running that script and set it to false. I'll re-run your asp link and see what's returned. Right now it returns:

Request.ServerVariables("remote_addr") :195.42.92.165
Request.ServerVariables("REMOTE_HOST") :m-200.ru

 



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Dmitry
Date Posted: 13 January 2004 at 10:00am

Ok

Now the EnableReverseDNS  is set to False



Posted By: dpyers
Date Posted: 13 January 2004 at 10:37am

This is what I get now...

Request.ServerVariables("remote_addr") :195.42.92.165
Request.ServerVariables("REMOTE_HOST") :195.42.92.165



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: Dmitry
Date Posted: 13 January 2004 at 12:06pm

I see same result

What's wrong on server?



Posted By: dpyers
Date Posted: 13 January 2004 at 2:17pm

Nothing was really wrong.

You have the server option to return either the IP address or the Reverse DNS lookup for a REMOTE_HOST. Your server was originally returning the reverse DNS lookup. When Morningz ran the script on his server, he got the ip address because that's what his REMOTE_HOST option was.

Most servers do return the ip address, but it's not required that they do so. The reverse dns lookup is also ok.



-------------

Lead me not into temptation... I know the short cut, follow me.


Posted By: meteor
Date Posted: 15 September 2004 at 1:37am
Hi .
i Search For Real Client IP Address.
if Clients use Proxy Or they Are Behind NAT how can i Get their IP Address even Virtual IP's.is any Scripts run on client and send to server Client Ip Address?
this is Very important to me...
Sorry For my Bad english

-------------
Sincerely
--------------------
http://www.TacPlusPlus.com - PowerFull Scripts For NTTacPlus


Posted By: meteor
Date Posted: 19 September 2004 at 4:07am

hi . in my previous post i wrote for Real Client Ip .
i see this in 1-counter.com .
how they get my client Ip . cookie?
i see in my stats 192.168.0.4 thatis my invalid Ip address ...
is ther any java script for getting client Ip address even if invalid address range ?????



-------------
Sincerely
--------------------
http://www.TacPlusPlus.com - PowerFull Scripts For NTTacPlus


Posted By: Mart
Date Posted: 19 September 2004 at 4:28am
When you request a page (or any object that comes from the server using HTTP) your  web browser sends your IP Address, so it is not from a cookie.  Your IP is showing up as 192.168.0.4 because you are probably behind a router. JS cannot get the client IP but you can use ASP then validate the IP address.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net