Print Page | Close Window

Ban more than 1 IP address

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=17203
Printed Date: 29 March 2026 at 5:07pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Ban more than 1 IP address
Posted By: sccs
Subject: Ban more than 1 IP address
Date Posted: 10 November 2005 at 8:57am

We have a contact form on our school website and we want to stop students from the school sending SPAM. There are 2 areas of the school and both have their own IP address. I managed to get it to work with one IP but I need to add 2 IP addresses in the code.

I tried this but it did not work:
 
Dim IP
IP= Trim(Request.ServerVariables("REMOTE_ADDR"))
IF IP = "***.**.15.87" OR IP= "***.**.15.67" THEN
        RESPONSE.REDIRECT("Warning.asp")
  
  
END IF
 
 
I have removed the numbers where * is for this message.
 
I tried it with just one IP address and it worked. I think I may have writen the code wrong for the other IP.
Thanks



Replies:
Posted By: dj air
Date Posted: 10 November 2005 at 9:10am
Dim IP
IP= Trim(Request.ServerVariables("REMOTE_ADDR"))

IF IP = "***.**.15.87" OR IP= "***.**.15.67" THEN
        RESPONSE.REDIRECT("Warning.asp")
  
  
END IF

i cant see why that wont work, what error problem are you getting with the above


Posted By: sccs
Date Posted: 10 November 2005 at 9:43am
It looks like we have a problem with the IP addresses at the school. Each computer has it's own IP. So trying to block each one may be hard. Or is it?


Posted By: dj air
Date Posted: 10 November 2005 at 9:50am
not sure how the script name   /   url   will help.

you want to block the IP Ranges, are they all on the same IP Ranges.


Posted By: sccs
Date Posted: 10 November 2005 at 9:57am
Please ignore my last message. I have just edited it.
 
It looks like we have a problem with the IP addresses at the school. Each computer has it's own IP. So trying to block each one may be hard. Or is it?


Posted By: dj air
Date Posted: 10 November 2005 at 10:01am
are they all on same IP Ranges, then you could block the ranges.


Posted By: sccs
Date Posted: 10 November 2005 at 10:03am
Yes. The first part is the same. it's just the last 15.67 that changes.


Posted By: dj air
Date Posted: 10 November 2005 at 10:12am
try

IP= Trim(Request.ServerVariables("REMOTE_ADDR"))
IP = Left(IP,7)

IF instr(1,IP, "xxxxxx") THEN
        RESPONSE.REDIRECT("Warning.asp")
  
  
END IF


where it has xxxxxx change that for the copmmon start of the IP Address

on the second line with 7 on it above change that to the number of charecters the beginig /common part is including the .


Posted By: sccs
Date Posted: 10 November 2005 at 10:40am
Thanks for that. It works great. Unfortunatelly the first part of the IP address is from the London Grid for Learning, so anyone filling in the form from another LGFL school will get a warning message. If it's urgent they can contact the school by phone or by using the e-mail link. It's just to stop students sending loads of crap e-mails.
 
Just one more question.
How do I ban other IP addresses.
 
Thanks for your help.
AndyTongue


Posted By: dpyers
Date Posted: 10 November 2005 at 3:22pm
Your school probably has a lock on the 3rd octet values -  .15. - and maybe a couple of other numbers in that position that aren't shared by other schools. You can use the instr method to just block xxx.yyy.15, xxx.yyy.16, etc.


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

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



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