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

request.servervariables("remote_addr") returning server IP address

Status
Not open for further replies.

masaville

Technical User
Joined
Apr 5, 2005
Messages
3
Location
CA
We host remotely and are transferring our site from one server to another. All of our ASP code is working, except I have found that 'request.servervariables("REMOTE_ADDR")' is returning the server's IP address instead of the visitors. I set up two identical pages on both servers to verify it using the code below.

Hello visitor from IP <%= Request.ServerVariables("REMOTE_ADDR") %>

Any idea why the new server would return the server's IP instead of the visitors?
 
I made a little page to help me with this type of problem. Maybe it will help you!

Just cut and paste the code below into a new ASP.

I named mine ServerVars.asp but you can obviously give it whatever name you like.

Code:
<%@ Language=VBScript %>
<html>
	<head>
		<title>What's in the Request.ServerVariables collection?</title>
	</head>
	<body>
		<table border="1">
			<tr>
				<th>Item</th>
				<th>Value</th>
			</tr>
<%
Dim oItem
For Each oItem in Request.ServerVariables 
%>
			<tr>
				<td valign="top"><%= oItem %> &nbsp;</td>
				<td valign="top"><%= Request.ServerVariables(oItem) %> &nbsp;</td>
			</tr>
<%		
Next
%>
		</table>
	</body>
</html>
 
Hi Scheco,

Thanks for your post. I run that script. On the old server (IIS 5.0) it reports the remote_addr as the visitor's IP. On the new server it reports it as server's IP.

Not sure where to look at this point. All the other ASP code works except for remote_addr. I presume this has something to do with server configuration?
 
Same for REMOTE_HOST ?
 
Yes. New host has 216.251.42.39 as the remote_addr and the remote_host. That's the server's IP.

The old host shows 24.86.30.115 for remote_addr and remote_host, which is my IP.

We use the remote_addr script to detect the visitor's IP for redirection.
 
This probably won't make you feel any better but it works on my dev box running IIS 5.1 on WinXP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top