Thread: IP Blocking
View Single Post
Old 04-19-2009, 08:02 AM   #1 (permalink)
Lucifer
Husband of Seamaiden
 
Lucifer's Avatar
 
Location: Nova Scotia
IP Blocking

I just learned how to do this, and I'm so pleased with myself that I thought I would share for all.

A little backstory: I discovered the other day that my fiancee's ex (in the immortal words of Al Pacino, "a large-type asshole") had visited our wedding website. I decided to try to block any future access of his, and stumbled across this elegant solution.

Notice, this needs an Apache server to work:

Create a file in your site root called .htaccess and in it place the following code:

order allow,deny
deny from 192.168.44.201
deny from 224.39.163.12
deny from 172.16.7.92
allow from all

The example above shows how to block 3 different IP addresses. Sometimes you might want to block a whole range of IP addresses:

order allow,deny
deny from 192.168.
deny from 10.0.0.
allow from all

The above code will block any IP address starting with "192.168." or "10.0.0." from accessing your site.

Finally, here's the code to block any specific ISP from getting access:

order allow,deny
deny from some-evil-isp.com
deny from subdomain.another-evil-isp.com
allow from all


so I blocked his home ip address, his company ip address, and just for good measure, I blocked his entire ISP from accessing the site.
__________________
I am a brother to dragons, and a companion to owls.
- Job 30:29

1123, 6536, 5321
Lucifer is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76