Search Tools Links Login

Determine if the remote computer has a local or internet IP address

if you have to determine if the remote computer visitor is local or external of your site and according to the case, for exemple redirect the user to the correct page...

Original Author: D. Jimmy


This range of addresses shows constant IP of a LAN and never a computer will have this IP on internet (Private IP address ranges as specified in RFC 1918).
' ->
' ->
' ->
But don't forget :
A Lan administrator can configure a LAN computer with an address IP out of the LAN range above.
With disabling "Allow Anonymous Access" on your application in IIS, you can know if the user of the remote computer was logged (and be on the LAN).
To do that get in String variable the logon with request.serverVariables.item("LOGON_USER").
An empty String means the user is not logged.


dim ArrayIPLocalStart(2)
dim ArrayIPLocalEnd(2)
Dim ArrayIPClient
Dim IPClient
dim blnLocal
Ipclient = Request.ServerVariables("REMOTE_ADDR")
Response.Write "Your IP is " & ipclient & "
blnLocal = false
' These IP address are constant IP of a LAN
ArrayIPLocalStart(0) = "" '""
ArrayIPLocalEnd(0) = "" '""
ArrayIPLocalStart(1) = "" '""
ArrayIPLocalEnd(1) = "" '""
ArrayIPLocalStart(2) = "" '""
ArrayIPLocalEnd(2) = "" '""
ArrayIPClient = split(Ipclient,".")
' format the remote IP like constant LAN IP
for i = lbound(ArrayIPClient) to ubound(ArrayIPClient)
ArrayIPClient(i) = string(3-len(ArrayIPClient(i) ),"0") & ArrayIPClient(i)
IPClient = join(ArrayIPClient,"")
if trim(ipclient) <> "" then
for i = lbound(ArrayIPLocalStart) to ubound(ArrayIPLocalStart)
ArrayIPLocalStart(i) = replace(ArrayIPLocalStart(i),".","")
ArrayIPLocalEnd(i) = replace(ArrayIPLocalEnd(i),".","")
if IPClient >= ArrayIPLocalStart(i) and IPClient =< ArrayIPLocalEnd(i) then
blnLocal = true
exit for
End if
end if
if blnLocal then
Response.Write " And your computer has a local IP"
Response.Write " And your computer has a internet IP"
End if

About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 89 times




No attachments for this post

Loading Comments ...


No comments have been added for this post.

You must be logged in to make a comment.