[wellylug] Blocking bad IPs from server
John Durham
johndurh at spunge.org
Fri Jan 26 08:08:19 NZDT 2007
I have a list of over 3000 IP values that have been blocked from using
my perl scripts using code like this:
########### Check for restricted IP servers.
print "Checking your IP $remote <br>";
open (FH, $badips);
while (<FH>) {
chop $_;
if ($remote =~ /$_/i) {
print "Content-type: text/html\n\n";
print "<html><head><title>Sorry, You Can't operate
our service using that system!</title></head>\n";
print "<body bgcolor=white><br><center><font size=5
color=blue>\n";
print "<font color=red><b>Sorry, your server has been
blocked for suspected improper access (possibly infected with a
bot!)</b></font><br>\n";
print "We identified your origin as $remote
!</b></font><br>It has been blocked due to reported spamming or other
suspicious activity.<br>\n";
print "<blink>To get it un-blocked, please use the
contact information on this page <a
href=\"http://www.modecideas.com/mainindex.html\">Webmaster</a> (bottom
right)</blink><br>";
print "<b>Please hit your browser's \"back\" button and
try again.</b></center><br>\n";
$errormessage = "Blocked IP attempted access!!";
&errorpage;
$msg = "Error $errormessage Exit 628";
&runlog;
#print "Exit 628";
#&updateme;
exit;
}
}
close (FH);
print "I guess your IP is OK!<br>";
--------------------------------------
The thing is, while scripts can be protected this way, how can the same
thing be done with a Ubuntu or other Linux server? Note: I have read the
method for treating individual ones at
http://www.cyberciti.biz/faq/how-do-i-block-an-ip-on-my-linux-server/
which seems possible, but imagine repeating it that many times?
--
Regards, John Durham <http://modecideas.com/contact.html?sig>
Fax/Phone 64 4 5286786
Award winning web site at http://modecideas.com?sig
Server hosted on Ubuntu 4.10
PC-HELPERS list subscribe/unsub at http://modecideas.com/discuss.htm?sig
Good advice is like good paint- it only works if applied.
More information about the wellylug
mailing list