...

View Full Version : Trying to block a range of IP address



shootertec
10-06-2003, 01:54 AM
I found a trick little script to block an indivual IP address. However the offender that I'm trying to block access to my web site has an ip address within a range.
I want to either be able to block the entire range or a easy way to list the 8 or so known IPs I want to block.

<script language="javascript">
var ip = '<!--#echo var="REMOTE_ADDR"-->'
if (ip == '206.186.23.178') {
alert("STOP! You are viewing this page from an IP address that is not allowed!");
{location.href="http://www.yahoo.com" } else { ("OK you choose I don't care! Bye bye! Don't come back!"); {location.href="http://www.yahoo.com" }} }
</script>

Trying to block 209.255.8.30 thru 209.255.8.40

I'm am very new to all of this so any and all help will be great!
Thanks!!

A1ien51
10-06-2003, 02:50 AM
the person still can view your page by turning javascript off, it is better to do this all on the server side,.....

but here is what you asked for.....



var ip = '<!--#echo var="REMOTE_ADDR"-->'
ipParts = ip.split(".");
if(parseInt(ipParts[3])>=30 && parseInt(ipParts[3])<=40){

shootertec
10-06-2003, 03:04 AM
Thanks so much for the quick reply, but where do I place this inside the original script. Or is this the entire script as is?

You said I should turn it off on the server side. What does that mean and how is it accomplished. I just curious really. The person I'm blocking isn't very bright and would unlikely know to turn off the java script. I didn't even know it would do that.

This script you provided, will this only block the IP address I mentioned and allow all others to enter?

Thanks

A1ien51
10-06-2003, 04:14 PM
<script language="javascript">
var ip = '<!--#echo var="REMOTE_ADDR"-->';
ipParts = ip.split(".");
if(parseInt(ipParts[3])>=30 && parseInt(ipParts[3])<=40){
alert("STOP! You are viewing this page from an IP address that is not allowed!");
{location.href="http://www.yahoo.com" } else { ("OK you choose I don't care! Bye bye! Don't come back!"); {location.href="http://www.yahoo.com" }} }
</script>

you just needed to add it where th if staement was...all i am saying if you would use a server side code, asp or jsp you would not have to worry about the person turing off their javascript in their browser.

This willwor for the range you specify....



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum