A recent Ubuntu convert asked me how to block IPs in Linux. He wanted something that was compatible with the PeerGuardian format (description:xxx.xxx.xxx.xxx-yyy-yyy-yyy-yyy). I didn't know of one off the top of my head so Googled it and found linblock. This is a handy little script that parses those IP blocklists you can get at sites like Bluetack. These blocklists can keep you safe from various types of hosts on the net like ad agencies, IPs that are under investigation by the authorities, and lists created from firewall and IDS logs that indicate that they are known for portscanning or other activities.

All you have to do with this script is extract it, open a terminal and type
perl -u blocklist -c chainname
Where blocklist is the name of the text file and chainname is just a name for that chain. If you want to use more than one blocklist file, you'll have to use a different chain name for each one of them.

If you want to roll your own blacklist, you can block ip addresses or networks manually with

iptables -A INPUT -s <iprange> -j DROP

You can substitute <iprange> with a single ip, or a range of ips such as 192.168.0.1-192.168.3.254