CodeGrabber
{ USER }
posts: 23
last: 28-Apr-2008
TITLE: Quick and Dirty Host Blocking in Linux
DESCRIPTION: Very simple hosting block technique
Submitted: 28-Apr-2008 00:47:58 ( 1yrs 45w 2d 16h ago ) Language: BASH (*.sh)
Views: 1307 Lines of Code: 10 LINES
Rating:
rate: star1
star2
star3
star4
star5
dstar1
dstar2
dstar3
dstar4
dstar5  ( rated! )
  { 4.00 / 5 }
Difficulty: Intermediate
Bookmark

If you are being attacked or abused by a particular host, just enter the following command to deny all access to the host:

/sbin/route add -host reject

Replace with the IP address of the host you want to block. The address will stay blocked until you bounce the interface. Alternatively, you could allow access by:

 

/sbin/route del -host reject

 

For a more permanent rejection, of course, use your firewall. If you really want this to persist, add the command to rc.local or whatever your favorite is.