Need to block IP via javascript

  Mr A! 12:32 26 Nov 04

I need to block a couple of ip addresses via a javascript file (block.js). This is then linked into all my asp pages using the include script. Can anybody help me with the script to block various ip addresses.

  Taran 17:46 26 Nov 04

Use this as your search field:

"JavaScript"+ban IP address

You get about 30,700 returns from Google. Those on the first page include this selection:

click here

click here

click here

click here

Just so that you know, JavaScript IP banning is about as effective as the M25 is at reducing traffic congestion.

You should go with a fully blown ASP/PHP/.NET coded script and forget fooling around with JavaScript if you want really strong results which are easier to look after over time. Managing a large JavaScript IP banning script becomes irritating after a while. The dynamic languages all lend themselves to this sort of task very well, without having to reference external JS files for help.

There's nothing stopping you from storing the IPs in your database and reading the list to be banned from it. Long term management becomes far easier when you think along these lines.


  Mr A! 09:42 29 Nov 04

right direction to finding an ASP IP banning script (which is free is possible)?

  Taran 01:55 30 Nov 04

I should really have pointed out that banning by IP address isn't necessarily 100%
reliable. As long as proxy servers, IP masking, and similar dodges exist, it is possible to get around IP banning, but this requires a far more advanced knowledge that about 99% of the web's users have.

And so...

Try the Aspin site click here and run a search in the Tutorials section for:

IP banning


Ban IP

If you wanted to play with one of many PHP solutions, there is a nice and simple script you can look at on the PHPFreaks site click here

It's a bit oversimplified to be a serious use, but it serves to demonstrate the concepts involved and is a useful learning experience.

If you have direct access to the web server, Windows IIS has built in IP banning. It works well but is a little limited - use the edit button on the Directory Security tab of the web site properties dialog, labelled "ip address and domain name restrictions". You can select one or a range of IP's to ban.

If you have direct access to the web site's firewall you could configure it to manage banned IP's, which is probably far more effective and certainly easier to manage, always assuming you have access to it to begin with of course.

A couple of nice sample ASP scripts are available click here click here

One licensed product can be seen click here

Basically, there are tons of resources available and most of them only take a bit of Googling to find.


This thread is now locked and can not be replied to.

Nintendo Switch (Nintendo NX) release date, price, specs and preview trailer: Codename NX console…

1995-2015: How technology has changed the world in 20 years

8 things designers (and brands) need to know about the modern woman

How to speed up a slow Mac: 19 great tips to make an iMac, MacBook or Mac mini run faster | Speed…