A lot of spam originates from servers located in China, Taiwan, HongKong and Korea. I don't plan to receive mail from these countries in a foreseeable future; yet, spamassassin doesn't catch all the spam they send me.
Let's combine three powerful tools against spam :
Get the source: chinaspam.c
insmod ip_queue
gcc -lGeoIP -lipq -o chinaspam chinaspam.c
iptables -A INPUT -m state --state NEW -i $IF_FREE -p tcp --dport smtp -j QUEUE
./chinaspam CN TW HK KR &Check the complete list of ISO3166 country-codes at http://www.maxmind.com/app/iso3166
tail -f /var/log/daemon.log
If 'chinaspam' process doesn't run, or stops running, iptables will not let pass any matching packet. Be warned, and monitor the process using Bernstein's daemontools
About speed: there is no NS-lookup involved, so the code is fast. GeoIP's benchmark reports around 10000 queries per second using the "free country database" on a PentiumPro200
Jun 14 17:25:18 zboubi chinaspam: Dropped a packet from 218.190.18.249 because it came from non-authorized country : Hong Kong Jun 14 17:25:27 zboubi last message repeated 2 times Jun 14 17:28:04 zboubi chinaspam: Dropped a packet from 218.79.117.171 because it came from non-authorized country : China Jun 14 19:38:20 zboubi chinaspam: Dropped a packet from 166.104.200.92 because it came from non-authorized country : Korea, Republic of Jun 14 19:38:29 zboubi last message repeated 2 times Jun 14 22:13:29 zboubi chinaspam: Dropped a packet from 221.124.77.241 because it came from non-authorized country : Hong Kong Jun 14 22:35:58 zboubi chinaspam: Dropped a packet from 222.65.101.153 because it came from non-authorized country : China Jun 14 22:36:07 zboubi last message repeated 2 times