I created a script to notify the abuse@ person for an IP address, while simultaneously banning that IP address for a time-period using fail2ban.
In my case this is useful for spam that I receive through a web based contact form. I don’t want to put a captcha on the form, and most of the spam was coming from the same IPs every day.
This script depends on curl, pcregrep and fail2ban. You could replace fail2ban with iptables however setting an expiration date with iptables alone is more complicated. Since I use fail2ban everywhere (and you should too), this method is just easier. pcregrep is required for doing a multi-line regex match.
email=$(curl iptool.xyz/$1/ | pcregrep -M -o1 'orgabuseemail:\s*[-\s]*(.*)')
sudo fail2ban-client set ipbans banip $1
echo -e "Today I received a spam attack from an IP address on your network. The offending IP is: $1.\n\nThe e-mail was sent using a web form, so the headers are of no special use.\n\nI have banned $1 from my network for 1 week. I recommend you take action to notify the persons responsible for that IP." | mail -s "Spammer on your network at $1" $email