Thursday, July 17, 2008

Block an IP with Route command

To block an IP address in the server with ‘route’ command in the kernel routing table.

# route add IP_ADDRESS reject

To view the status :

# netstat -nr
# route -n

You can verify whether the ‘FLAG’ of the IP address is ‘!H’

To remove the block:

# route del IP_ADDRESS reject

You can also specify the IP ranges with corresponding Subnet Mask.

# route add -net IP_ADDRESS netmask 255.255.XXX.XXX reject

No comments: