Well, Pyronexus started to gain a bit more attention recently – by bots at least – either that or Google’s reCaptcha just stopped working as well.
So I started to look for new ideas. Since I cannot stand spammers I thought the best way to avoid them was to block them. I knew iptables would suit my needs but it isn’t always the easiest to configure.
A quick google search later and I came across a post of an author who’d encountered the same problem and had already beaten me to the solution.
However, I noticed some areas where his script could improved. So here it is if anyone else needs it :).
- Create a directory for the script to reside in and create a new file:
mkdir -p /opt/scripts nano /opt/scripts/iptables_spamhaus.sh
- Paste the following into it, and edit the variables such as iptables save path:
- Save the file, then make it executable:
chmod +x /opt/scripts/iptables_spamhaus.sh
- Now, edit your crontab and add a new job to update every day or so (not too much, you don’t want to overload their servers by constantly updating). You can use my crontab example which runs every night at midnight:
@reboot /opt/scripts/iptables_spamhaus.sh @daily /opt/scripts/iptables_spamhaus.sh
- Give it a test run and list the iptables rules (It will take a while as they resolve into hostnames, but you will see the Spamhaus chain appearing – press CTRL + C to cancel the listing):
/opt/scripts/iptables_spamhaus.sh iptables --list-rules