Skip to content

Instantly share code, notes, and snippets.

@enonethreezed
Last active October 21, 2017 05:53
Show Gist options
  • Save enonethreezed/c43ac78b25453bea50d0016d58a94353 to your computer and use it in GitHub Desktop.
Save enonethreezed/c43ac78b25453bea50d0016d58a94353 to your computer and use it in GitHub Desktop.
This script will read from rsyslog pipe and block any IP (if desired) that does an unauthorized AXFR petition.
#!/bin/bash
somepipe=/var/log/rsyslog.pipe
while true
do
if read line <$somepipe
then
if grep -i --line-buffered -P '^(?=.*named)(?=.*cache)(?=.*denied)' $line;
then
offendingIP="$(grep -P '^(?=.*named)(?=.*cache)(?=.*denied)' $line | egrep '([0-9]{1,3}\.){3}[0-9]{1,3}')"
echo Your offending IP is $offendingIP
# AYOR
# iptables -A INPUT -i eth0 -s $offendingIP -j DROP
f
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment