(OLDER) <- More Stuff -> (NEWER) (NEWEST)
Printer Friendly Version



Blocking Unwanted Visitors


2009/03/04



Yesterday I happened to notice unusual web activity coming from a set of Hong Kong addresses. A half dozen ip addresses were walking my site, following every link.

I don't really get too upset by that sort of activity. I know that people around the world do that, sometimes to steal content but sometimes just so they can have a local cache. Sometimes it may be a previously unknown search engine collecting information. That's fine.. except..

Legitimate spidering programs should honor my robots.txt which asks them NOT to follow cgi links. This idiot program was using multiple ips and following all the "Comment" and "Printer Friendly" cgi links at a very rapid pace, slowing down the server for everyone else. I can't have that, so I added him to my "bad ip" list.

Most cgi scripts here have a section in them that looks like this:


$rip=$ENV{'REMOTE_ADDR'};
open(BADRIP,"$DATA/badrip");
while (<BADRIP>) {
 chomp;
 if ($rip =~ /^$_/) {
print <<EOF;
Content-type: text/html

<script language="javascript"><!--
location.replace("http://192.0.2.1")
//-->
</script>
EOF
   
exit 0;
 }
} 
close BADRIP;
 

The idea is to redirect him to something that won't resolve, thereby slowing him down. I could do the same thing with pages (and if he keeps on being annoying I will).

I don't leave the ip's in the "badrip" file for more than a few hours - these are almost always DHCP addresses that will recycle to someone else soon enough. Most of the time the "badrip" is empty; it's only when someone becomes really annoying that I use this.

We've talked about blocking by country before:
More ssh ideas
ARIN, APNIC, LAPNIC, RIPE

I don't want to arbitrarily block by country. Yes, an awful lot of "problem" access comes from Asian countries, but I don't see that as reason to lock out everyone from those ip blocks. There is a lot of Asian access because there are a lot of Asian people, and while some of the spidering may be for theft, it can also be for legitimate reasons (though legitimate spiders should be honoring my robots.txt). I'll just continue to handle it on a case by case basis.




Click here to add your comments



Don't miss responses! Subscribe to Comments by RSS or by Email

Click here to add your comments


If you want a picture to show with your comment, go get a Gravatar



numly esn 30797-090304-225105-10
numly barcode

Have you tried Searching this site?

Unix/Linux/Mac OS X support by phone, email or on-site: Support Rates

This is a Unix/Linux resource website. It contains technical articles about Unix, Linux and general computing related subjects, opinion, news, help files, how-to's, tutorials and more. We appreciate comments and article submissions.

Publishing your articles here

Jump to Comments



Many of the products and books I review are things I purchased for my own use. Some were given to me specifically for the purpose of reviewing them. I resell or can earn commissions from the sale of some of these items. Links within these pages may be affiliate links that pay me for referring you to them. That's mostly insignificant amounts of money; whenever it is not I have made my relationship plain. I also may own stock in companies mentioned here. If you have any question, please do feel free to contact me.

Specific links that take you to pages that allow you to purchase the item I reviewed are very likely to pay me a commission. Many of the books I review were given to me by the publishers specifically for the purpose of writing a review. These gifts and referral fees do not affect my opinions; I often give bad reviews anyway.

We use Google third-party advertising companies to serve ads when you visit our website. These companies may use information (not including your name, address, email address, or telephone number) about your visits to this and other websites in order to provide advertisements about goods and services of interest to you. If you would like more information about this practice and to know your choices about not having this information used by these companies, click here.

book graphic Internet Income guide

My Hard Truths about Easy Money on the Internet will show you how to make money on the Internet!

 I sell and support
 Kerio Mail server




pavatar.jpg
More:
       - Blogging
       - Networking
       - Web/HTML


Unix/Linux Consultants

Skills Tests

Guest Post Here











My Favorites

Change Congress