fail2ban is not "for http", it's a framework for taking actions (like banning IPs at the firewall) based on log entries. Here are the relevant configuration options from my DNS server:
named.conf
logging {
channel default_file {
file "/var/log/named.log" size 10m;
severity info;
print-time yes;
print-severity yes;
print-category yes;
};
category default{ default_file; };
};
jail.local
(fail2ban's configuration file)
[named-refused-bsd-ipfw]
enabled = true
filter = named-refused
action = bsd-ipfw
logpath = /var/named/var/log/named.log
maxretry = 20
bantime = 43200
Note that this is a FreeBSD box using IPFW (firewall). You'll want to use action iptables and name the rule appropriately.
You may also need to change the log paths, depending on your installation. Note that in my example there are different paths because BIND is running in a jail (chrooted to /var/named). Running in a jail makes things more complicated, but not bad once you get used to it.
You should also setup some sort of log rotation mechanism for the log file.
newsyslog.conf
/var/log/named.log bind:bind 644 7 * $W6D0 J /var/run/named/pid 1
You may also want to take a look at who it is, it may be an open resolver (like Google, 4.2.2.2-.4, etc). Banning them doesn't ban the real "attacker". You can do a reverse lookup on the IP with something like dig -x 4.2.2.4 and see if that helps.