При попытке запуска fail2ban для ssh на Linux OrangePI 3.4.39 возникла проблема - не создаются правила iptables, в лог пишет возврат кода 100. Возможно, подобная проблема проявляется и в других дистрибутивах на Raspberry (Raspbian) и подобных одноплатных компьютерах. Корень проблемы - отсутствие multiport в iptables и некоторые проблемы с параллелизмом. Пересобирать ядро было лень, поэтому я нашел другое решение.
В файле /etc/fail2ban/action.d/iptables-multiport.local
Исправляем actionstart и actionstop до такого вида:
# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
# Values: CMD
#
actionstart = sleep 1
iptables -N fail2ban-<name>
sleep 1
iptables -A fail2ban-<name> -j RETURN
sleep 1
sleep 1
iptables -w -I <chain> -p <protocol> --dport <port> -j fail2ban-<name>
#OLDCODE iptables -I <chain> -p <protocol> -m multiport --dports <port> -j fail2ban-<name>
# Option: actionstop
# Notes.: command executed once at the end of Fail2Ban
# Values: CMD
#
actionstop = sleep 1
iptables -w -D <chain> -p <protocol> --dport <port> -j fail2ban-<name>
sleep 1
iptables -F fail2ban-<name>
sleep 1
iptables -X fail2ban-<name>
#OLDCODE iptables -D <chain> -p <protocol> -m multiport --dports <port> -j fail2ban-<name>
https://putty.org.ru/articles/fail2ban-ssh.html
Подобные проблемы:
https://www.stableit.ru/2010/02/fail2ban.html
https://sourceforge.net/p/fail2ban/bugs/47/
https://github.com/fail2ban/fail2ban/issues/2211
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=554162
Решение
Копируем /etc/fail2ban/action.d/iptables-multiport.conf в /etc/fail2ban/action.d/iptables-multiport.localВ файле /etc/fail2ban/action.d/iptables-multiport.local
Исправляем actionstart и actionstop до такого вида:
# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
# Values: CMD
#
actionstart = sleep 1
iptables -N fail2ban-<name>
sleep 1
iptables -A fail2ban-<name> -j RETURN
sleep 1
sleep 1
iptables -w -I <chain> -p <protocol> --dport <port> -j fail2ban-<name>
#OLDCODE iptables -I <chain> -p <protocol> -m multiport --dports <port> -j fail2ban-<name>
# Option: actionstop
# Notes.: command executed once at the end of Fail2Ban
# Values: CMD
#
actionstop = sleep 1
iptables -w -D <chain> -p <protocol> --dport <port> -j fail2ban-<name>
sleep 1
iptables -F fail2ban-<name>
sleep 1
iptables -X fail2ban-<name>
#OLDCODE iptables -D <chain> -p <protocol> -m multiport --dports <port> -j fail2ban-<name>
При этом возможно нарушение работы fail2ban со списками портов, но я эту функцию не использую. Как вариант решения - можно убрать --dports <port> и блокировать все порты адреса.
Доп. материалы
Мануал по настройке:https://putty.org.ru/articles/fail2ban-ssh.html
Подобные проблемы:
https://www.stableit.ru/2010/02/fail2ban.html
https://sourceforge.net/p/fail2ban/bugs/47/
https://github.com/fail2ban/fail2ban/issues/2211
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=554162
Комментариев нет:
Отправить комментарий