Forum Moderators: mack

Message Too Old, No Replies

Ban IP Addresses

Never had to before

         

Dayo_UK

7:09 am on Sep 19, 2003 (gmt 0)



OK, I have never had to ban IP addresses before and I have seen various people mention .htaccess files - but I dont know the first thing about banning a particular IP address or htaccess.

But this morning I have had 6351 accesses from IP address 64.230.83.149 with the user agent "Java/1.4.1_05" "-" for a 200 page site - and this has really p****d me off. (In fact all the accesses were to a sub folder which only contains about 10 files!)

Anyone know of a beginners way to get started on banning some IPs?

JamesR

4:43 pm on Sep 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe it is just

deny from 64.230.83.149

pendanticist

5:00 pm on Sep 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You'll do better by your site to ban the harvestor and not the IP Number due to the volume of those using some form or other of Java.

Might I suggest reading thru this thread?

How to protect from site copiers like teleport?
How to stop undesired crawlers and spiders
[webmasterworld.com]

Pendanticist.

Dayo_UK

5:35 pm on Sep 19, 2003 (gmt 0)



James and Pendanticist - Thanks for your help so far.

So, in notepad create a file called .htaccess.txt

and insert the following (example)?


<Files .htaccess>
deny from all
</Files>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} ^EmailSiphon [OR]
RewriteCond %{HTTP_USER_AGENT} ^EmailWolf [OR]
RewriteCond %{HTTP_USER_AGENT} ^ExtractorPro [OR]
RewriteCond %{HTTP_USER_AGENT} ^Mozilla.*NEWT
RewriteRule ^.* - [F]
RewriteCond %{HTTP_REFERER} ^http://www.iaea.org$
RewriteRule!^http://[^/.]\.your-site.com.* - [F]

This list is the beginning of Toolmans list in this thread:-
[webmasterworld.com...]

The your-site.com should be changed to my-domain.co.uk

and if I wanted to add useragents I would insert a new line - each line needs an [OR] on the end except the last user agent, so if I wanted to ban the user agent from my first post it would be something like :-

RewriteCond %{HTTP_USER_AGENT} ^Java/1.4.1_05 [OR]

This file should be saved and uploaded to the root and renamed .htaccess

Can anyone confirm if the above is correct or if I am going wrong somewhere?

If you view Toolmans post on the above thread he has said (the top bit is left out) - should there be something above <Files .htaccess>?

[edited by: Dayo_UK at 5:38 pm (utc) on Sep. 19, 2003]

JamesR

5:38 pm on Sep 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



actually it must be named just .htaccess, no other file extension after it. Sometimes when you FTP it into the root directory of your site, you won;t see the file because some FTP programs are not set to recognize the .htaccess file type. You have to tweak the FTP program to recognize it (Leech FTP was like that)

JamesR

5:40 pm on Sep 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your hosting plan has to be set up to handle mod rewrite for toolman's example to work (most should be set up but double check). When I first uploaded that, I couldn't browse my site because mod rewrite was not set up yet.

Dayo_UK

5:43 pm on Sep 19, 2003 (gmt 0)



Thanks for talking me through this James :)

The comment (the top bit is left out) - should there be anything before <Files .htaccess>?

I will have to test it on one of my smaller sites first me thinks ;)

claus

6:13 pm on Sep 19, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Dayo_UK, start with a basic version, it's so much easier to troubleshoot and you can always add other pests than the "Java" one if the need arises.

>> the top bit is left out

The .htaccess file can be used for a lot of purposes. I don't really know what Toolman has in the beginning of his .htaccess file but it could very well be something that did not concern banning of bots.

You might need the top two lines of the minimalist example below, but it's not certain that they are required on your server, it depends on the configuration:

Options +FollowSymlinks 
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^Java [NC]
RewriteRule .* - [F,L]

What this does is:

  1. it enables symbolic links (might be necessary)
  2. it enables the rewrite engine (might be necessary)
  3. it looks for a User Agent String that starts with the letters "Java" (NC makes it case insensitive)
  4. it sends a "403 Forbidden" no matter what this User Agent asks for

If you need to add more User-Agents or IPs or whatever, just make the [NC] an [NC,OR] and insert a new line.

For further reading, here's part 2 of "A close to perfect .htaccess ban list" - the full thread is around 20 or so pages now, but it contains a lot of good advice.

[webmasterworld.com...]

/claus

mplove

8:26 pm on Oct 22, 2003 (gmt 0)



Hi Everyone.

I am new here, have spent the last 2 hrs going through the posts in hope of finding a solution to my problem.

Let me say that I am TOTALLY NOT computer literate. Phew! Now that that has been said, here is my problem.

I want to deny a few IP address access to my site, but have absolutely NO clue as to how to go about it.
I use FrontPage to build my pages, if this makes a difference?!

Any help would be greatly appreciated! Remember though, if you can help me, it has to be a step-by-step direction! :)