Created
December 19, 2018 20:29
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tested on postfix version 2.11.0