Random Ramblings
Mystery fail2ban failures
January 19, 2012 at 10:00 AM | categories: hacking aroundWhile trying to set up fail2ban to watch the gNewSense MoinMoin instance (It powers the main website and the wiki) I hit an error which didn't seem to make any sense
My filter called 'moinmoin-page-with-spaces' was inexplicably causing fail2ban to return error 200. Annoyingly, my moinmoin-captcha filter appeared to loading perfectly, and both were syntactically identical.
2012-01-19 05:21:09,093 fail2ban.jail : INFO Jail 'moinmoin-page-with-spaces' started 2012-01-19 05:21:09,141 fail2ban.jail : INFO Jail 'moinmoin-captcha' started 2012-01-19 05:21:09,215 fail2ban.jail : INFO Jail 'ssh' started 2012-01-19 05:21:09,213 fail2ban.actions.action: ERROR iptables -N fail2ban-moinmoin-page-with-spaces iptables -A fail2ban-moinmoin-page-with-spaces -j RETURN iptables -I INPUT -p tcp -m multiport --dports www -j fail2ban-moinmoin-page-with-spaces returned 200 2012-01-19 05:28:20,779 fail2ban.jail : INFO Jail 'moinmoin-captcha' stopped 2012-01-19 05:28:21,077 fail2ban.jail : INFO Jail 'ssh' stopped 2012-01-19 05:28:21,364 fail2ban.actions.action: ERROR iptables -D INPUT -p tcp -m multiport --dports www -j fail2ban-moinmoin-page-with-spaces iptables -F fail2ban-moinmoin-page-with-spaces iptables -X fail2ban-moinmoin-page-with-spaces returned 200 2012-01-19 05:28:21,904 fail2ban.jail : INFO Jail 'moinmoin-page-with-spaces' stopped 2012-01-19 05:28:21,910 fail2ban.server : INFO Exiting Fail2ban
Upon running the iptables commands individually it turned out that it was iptables returning 200 (not fail2ban).
Seems that iptables has a maximum string size of 30 chars for its labels. Because fail2ban adds 'fail2ban-' and your filter name together it was pushing the total string length ('fail2ban-moinmoin-page-with-spaces') to 35 chars long. Resolving the issue meant renaming the filter down until it was under 20 chars, so fail2ban could add its 9 chars onto the front and still be ok.