Restrict access by ip

T

Ted Boyd

I have an ASP page that I want to allow access from only from a certain
block of address, can someone get me started?
 
M

McKirahan

Ted Boyd said:
I have an ASP page that I want to allow access from only from a certain
block of address, can someone get me started?


Is it a list or a range of valid IP Addresses?

If a list then try this:

<%
Dim arrIPA(2)
arrIPA(0) = "1.2.3.4"
arrIPA(1) = "11.22.33.44"
arrIPA(2) = "111.222.333.444"
Dim strIPA
strIPA = Join(arrIPA,"^")
Dim strRSV
strRSV = Request.ServerVariables("REMOTE_ADDR")
If InStr(strIPA,strRSV) > 0 Then
'.............. IPAddress is valid ................
End If
%>
 
E

Evertjan.

McKirahan wrote on 04 okt 2006 in
microsoft.public.inetserver.asp.general:
Is it a list or a range of valid IP Addresses?

If a list then try this:

<%
Dim arrIPA(2)
arrIPA(0) = "1.2.3.4"
arrIPA(1) = "11.22.33.44"
arrIPA(2) = "111.222.333.444"
Dim strIPA
strIPA = Join(arrIPA,"^")
Dim strRSV
strRSV = Request.ServerVariables("REMOTE_ADDR")
If InStr(strIPA,strRSV) > 0 Then
'.............. IPAddress is valid ................
End If
%>

Not very safe, as it would allow:

181.2.3.4
211.2.33.44
etc.

Try:

Dim arrIPA(3)
arrIPA(0) = "1.2.3.4"
arrIPA(1) = "11.22.33.44"
arrIPA(2) = "111.222.333.444"
Dim strIPA
strIPA = "^" & Join(arrIPA,"^") & "^"
Dim strRSV
strRSV = "^" & Request.ServerVariables("REMOTE_ADDR") & "^"
If InStr(strIPA,strRSV) = 0 Then session.abandon : response.end

===

Even then I would think "REMOTE_ADDR" can be manipulated
in the client request stream.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top