Skip to content

Instantly share code, notes, and snippets.

@kimthostrup
Created December 19, 2018 20:29
Show Gist options
  • Save kimthostrup/b9ad1d084b69364efdac3e1384cbb3d2 to your computer and use it in GitHub Desktop.
Save kimthostrup/b9ad1d084b69364efdac3e1384cbb3d2 to your computer and use it in GitHub Desktop.
Ugly hack to download a couple of blocklist and use them in postfix
#!/bin/bash
# Go to our working directory
cd /tmp
# Download Blacklist
wget https://lists.blocklist.de/lists/all.txt --no-check-certificate
wget http://opendbl.net/lists/talos.list
# List cleaning
sed -i '1d' /tmp/talos.list
# Merge the blocklists
cat /tmp/talos.list >> /tmp/all.txt
# Make sure there are no duplicate IP's
sort all.txt | uniq > /tmp/iplist.tmp
# Add REJECT Your IP is spam
sed -i 's/$/\tREJECT Your IP is spam/g' /tmp/iplist.tmp
# Remove all IPv6 lines
grep -P "([0-9]{1,3}[\.]){3}[0-9]{1,3}" /tmp/iplist.tmp > /etc/postfix/client_checks
# Postmap convert
postmap -v /etc/postfix/client_checks
# Restart Postfix
service postfix restart
# Clean up temporary files
rm -f /tmp/all.txt /tmp/iplist.tmp /tmp/talos.list /tmp/all2.txt
@kimthostrup
Copy link
Author

Tested on postfix version 2.11.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment