Eu configurei o fail2ban 0.9.1 no meu Synology NAS para lidar com tentativas de SSH com falha. Quando inicio a cadeia, recebo os seguintes erros no fail2ban.log:
2015-02-01 17:22:52,394 fail2ban.jail [30576]: INFO Jail 'ssh-iptables-syno' started
2015-02-01 17:22:53,287 fail2ban.actions [30576]: NOTICE [ssh-iptables-syno] Ban 103.41.124.52
2015-02-01 17:22:53,613 fail2ban.action [30576]: ERROR iptables -I f2b-ssh-iptables-syno 1 -s 103.41.124.52 -j REJECT --reject-with icmp-port-unreachable -- stdout: ''
2015-02-01 17:22:53,625 fail2ban.action [30576]: ERROR iptables -I f2b-ssh-iptables-syno 1 -s 103.41.124.52 -j REJECT --reject-with icmp-port-unreachable -- stderr: 'iptables v1.4.21: unknown option "--reject-with"\nTry 'iptables -h\' or \'iptables --help\' for more information.\n'
2015-02-01 17:22:53,626 fail2ban.action [30576]: ERROR iptables -I f2b-ssh-iptables-syno 1 -s 103.41.124.52 -j REJECT --reject-with icmp-port-unreachable -- returned 2
Outro exemplo:
2015-02-01 17:22:54,525 fail2ban.actions [30576]: NOTICE [ssh-iptables-syno] Ban 222.161.4.147
2015-02-01 17:22:54,855 fail2ban.action [30576]: ERROR iptables -I f2b-ssh-iptables-syno 1 -s 222.161.4.147 -j REJECT --reject-with icmp-port-unreachable -- stdout: ''
2015-02-01 17:22:54,857 fail2ban.action [30576]: ERROR iptables -I f2b-ssh-iptables-syno 1 -s 222.161.4.147 -j REJECT --reject-with icmp-port-unreachable -- stderr: 'iptables v1.4.21: unknown option "--reject-with"\nTry 'iptables -h\' or \'iptables --help\' for more information.\n'
2015-02-01 17:22:54,858 fail2ban.action [30576]: ERROR iptables -I f2b-ssh-iptables-syno 1 -s 222.161.4.147 -j REJECT --reject-with icmp-port-unreachable -- returned 2
2015-02-01 17:22:54,860 fail2ban.actions [30576]: ERROR Failed to execute ban jail 'ssh-iptables-syno' action 'iptables-multiport' info 'CallingMap({'ipjailmatches': <function <lambda> at 0x40dfe0b0>, 'matches': u'warning\t2015/02/01 17:14:04\tSYSTEM:\tUser [root] from [222.161.4.147] failed to log in via [SSH] due to authorization failure.\nwarning\t2015/02/01 17:14:06\tSYSTEM:\tUser [root] from [222.161.4.147] failed to log in via [SSH] due to authorization failure.\nwarning\t2015/02/01 17:14:09\tSYSTEM:\tUser [root] from [222.161.4.147] failed to log in via [SSH] due to authorization failure.', 'ip': '222.161.4.147', 'ipmatches': <function <lambda> at 0x40dfe0f0>, 'ipfailures': <function <lambda> at 0x40dfe030>, 'time': 1422807774.52478, 'failures': 3, 'ipjailfailures': <function <lambda> at 0x40dfe070>})': Error banning 222.161.4.147
- > trecho de log completo: link
Quando tento executar o comando iptables diretamente, como recebo o seguinte erro:
# iptables -I f2b-ssh-iptables-syno 1 -s 222.161.4.147 -j REJECT --reject-with icmp-port-unreachable
iptables v1.4.21: unknown option "--reject-with"
Eu tenho outra máquina (12.04) com o iptables 1.4.21 e o fail2ban 0.9.1, onde tudo funciona perfeitamente. Aqui estão algumas informações do iptables para ambas as máquinas:
Maquina ruim:
# iptables --version
iptables v1.4.21
# cat /proc/net/ip_tables_targets
LOG
ERROR
# cat /proc/net/ip_tables_matches
limit
state
udplite
udp
tcp
multiport
multiport
icmp
Boa máquina:
# iptables --version
iptables v1.4.21
# cat /proc/net/ip_tables_targets
AUDIT
NFLOG
NFQUEUE
NFQUEUE
NFQUEUE
CLASSIFY
CONNMARK
CONNMARK
MARK
MARK
MARK
ULOG
TPROXY
TPROXY
MASQUERADE
REDIRECT
TOS
TOS
DSCP
LOG
TCPMSS
DNAT
SNAT
REJECT
ERROR
# cat /proc/net/ip_tables_matches
statistic
time
connlimit
realm
pkttype
connmark
connmark
physdev
string
string
owner
comment
conntrack
conntrack
conntrack
helper
limit
hashlimit
hashlimit
iprange
iprange
policy
owner
addrtype
addrtype
recent
state
length
ttl
tcpmss
multiport
multiport
tos
tos
dscp
icmp
udplite
udp
tcp
Alguma idéia de como abordar esses erros?
Atualizar
Graças ao @ricardo, descobri que o iptables no meu Synology (DSM 5) está sem o alvo REJECT. Não sei como adicioná-lo embora.