Portál AbcLinuxu, 10. května 2025 04:57

Dotaz: Debian Postfix + Fail2ban - ignoruje host.deny i iptables

1.4.2014 21:39 Daves
Debian Postfix + Fail2ban - ignoruje host.deny i iptables
Přečteno: 677×
Odpovědět | Admin
Zdravím všechny,
dva dny se trápím a hledám řešení, ale nic jsem nevygooglil.
Mám postfix a fail2ban, problém tkví v tom, že ač je IP zablokovaná, postfix to ignoruje.
Znáte řešení ?

2014-04-01 21:10:17,397 fail2ban.actions: WARNING [postfix] 208.73.211.199 already banned
2014-04-01 21:15:47,751 fail2ban.actions: WARNING [postfix] 208.73.211.235 already banned
2014-04-01 21:16:17,783 fail2ban.actions: WARNING [postfix] 208.73.211.172 already banned
2014-04-01 21:16:18,785 fail2ban.actions: WARNING [postfix] 208.73.211.196 already banned
2014-04-01 21:16:47,815 fail2ban.actions: WARNING [postfix] 208.73.211.199 already banned
2014-04-01 21:16:48,817 fail2ban.actions: WARNING [postfix] 208.73.211.152 already banned
2014-04-01 21:17:47,881 fail2ban.actions: WARNING [postfix] 208.73.211.172 already banned
2014-04-01 21:17:48,882 fail2ban.actions: WARNING [postfix] 208.73.211.152 already banned
2014-04-01 21:17:49,884 fail2ban.actions: WARNING [postfix] 208.73.211.196 already banned
2014-04-01 21:20:17,041 fail2ban.actions: WARNING [postfix] 208.73.211.172 already banned
2014-04-01 21:31:25,759 fail2ban.actions: WARNING [postfix] 208.73.211.172 already banned
2014-04-01 21:31:26,760 fail2ban.actions: WARNING [postfix] 208.73.211.152 already banned
2014-04-01 21:31:55,792 fail2ban.actions: WARNING [postfix] 208.73.211.196 already banned
2014-04-01 21:32:25,824 fail2ban.actions: WARNING [postfix] 208.73.211.235 already banned
2014-04-01 21:32:26,826 fail2ban.actions: WARNING [postfix] 208.73.211.199 already banned
2014-04-01 21:32:55,857 fail2ban.actions: WARNING [postfix] 208.73.211.235 already banned
2014-04-01 21:35:18,009 fail2ban.actions: WARNING [postfix] 208.73.211.235 already banned


Chain fail2ban-postfix (1 references)
target     prot opt source               destination
DROP       all  --  208.73.211.199       anywhere
DROP       all  --  208.73.211.235       anywhere
DROP       all  --  208.73.211.172       anywhere
DROP       all  --  208.73.211.152       anywhere
DROP       all  --  208.73.211.196       anywhere
DROP       all  --  208.73.211.161       anywhere
DROP       all  --  208.73.211.250       anywhere
DROP       all  --  208.73.211.167       anywhere
DROP       all  --  208.73.211.176       anywhere
DROP       all  --  208.73.211.249       anywhere
DROP       all  --  208.73.211.164       anywhere
DROP       all  --  208.73.211.182       anywhere
DROP       all  --  208.73.211.177       anywhere
DROP       all  --  208.73.211.236       anywhere
DROP       all  --  208.73.211.175       anywhere
DROP       all  --  208.73.211.165       anywhere
DROP       all  --  208.73.210.218       anywhere
DROP       all  --  208.73.211.168       anywhere
DROP       all  --  208.73.210.215       anywhere
RETURN     all  --  anywhere             anywhere

Musí se před postfix předřadit nějaká Proxy ?
Nástroje: Začni sledovat (0) ?Zašle upozornění na váš email při vložení nového komentáře.

Odpovědi

1.4.2014 21:57 Petr Šobáň | skóre: 80 | blog: soban | Olomouc
Rozbalit Rozbalit vše Re: Debian Postfix + Fail2ban - ignoruje host.deny i iptables
Odpovědět | | Sbalit | Link | Blokovat | Admin
Si vypiš pravidla firewalu prostě to projde nějakým pravidlem před zakázáným.
AraxoN avatar 1.4.2014 22:37 AraxoN | skóre: 47 | blog: slon_v_porcelane | Košice
Rozbalit Rozbalit vše Re: Debian Postfix + Fail2ban - ignoruje host.deny i iptables
Odpovědět | | Sbalit | Link | Blokovat | Admin
Tiež som toho názoru, že to nedoputuje do toho chainu "fail2ban-postfix". Skús hodiť výpis z príkazu iptables -L -n

Občas sa mi s fail2ban stane, že pridanie pravidla alebo chainu zlyhá. Skús reštartovať fail2ban a pozrieť či v logoch nie sú nejaké chyby.
1.4.2014 22:43 Daves
Rozbalit Rozbalit vše Re: Debian Postfix + Fail2ban - ignoruje host.deny i iptables
Blbnul jsem teď ještě s ufw, tak tam přibylo hodně ufw řádků, které tam prve nebyly. Pro všechny ostatní pravidla to funguje, SSH krásně blokuje. Ale Postfix jak kdyby to ignoroval. Ostatním to s Postfixem funguje ?

# iptables -L -n
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
fail2ban-dovecot  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-apache-myadmin  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-apache-w00tw00t  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-php-url-fopen  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-apache-noscript  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-apache-nohome  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-apache-badbots  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-webmin  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-postfix  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-pure-ftpd  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-apache-overflows  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-apache  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-ssh-ddos  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-pam-generic  all  --  0.0.0.0/0            0.0.0.0/0
fail2ban-ssh  all  --  0.0.0.0/0            0.0.0.0/0
DROP       udp  --  208.73.211.0/24      0.0.0.0/0
DROP       tcp  --  208.73.211.0/24      0.0.0.0/0
DROP       all  --  208.73.211.0/24      0.0.0.0/0
DROP       all  --  208.73.211.0/24      0.0.0.0/0
ufw-before-logging-input  all  --  0.0.0.0/0            0.0.0.0/0
ufw-before-input  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-input  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-logging-input  all  --  0.0.0.0/0            0.0.0.0/0
ufw-reject-input  all  --  0.0.0.0/0            0.0.0.0/0
ufw-track-input  all  --  0.0.0.0/0            0.0.0.0/0

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination
ufw-before-logging-forward  all  --  0.0.0.0/0            0.0.0.0/0
ufw-before-forward  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-forward  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-logging-forward  all  --  0.0.0.0/0            0.0.0.0/0
ufw-reject-forward  all  --  0.0.0.0/0            0.0.0.0/0

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
ufw-before-logging-output  all  --  0.0.0.0/0            0.0.0.0/0
ufw-before-output  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-output  all  --  0.0.0.0/0            0.0.0.0/0
ufw-after-logging-output  all  --  0.0.0.0/0            0.0.0.0/0
ufw-reject-output  all  --  0.0.0.0/0            0.0.0.0/0
ufw-track-output  all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-apache (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-apache-badbots (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-apache-myadmin (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-apache-nohome (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-apache-noscript (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-apache-overflows (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-apache-w00tw00t (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-dovecot (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-pam-generic (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-php-url-fopen (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-postfix (1 references)
target     prot opt source               destination
DROP       all  --  208.73.211.249       0.0.0.0/0
DROP       all  --  208.73.211.177       0.0.0.0/0
DROP       all  --  208.73.211.182       0.0.0.0/0
DROP       all  --  208.73.211.236       0.0.0.0/0
DROP       all  --  208.73.211.164       0.0.0.0/0
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-pure-ftpd (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-ssh (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-ssh-ddos (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain fail2ban-webmin (1 references)
target     prot opt source               destination
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

Chain ufw-after-forward (1 references)
target     prot opt source               destination

Chain ufw-after-input (1 references)
target     prot opt source               destination

Chain ufw-after-logging-forward (1 references)
target     prot opt source               destination
1.4.2014 22:50 Daves
Rozbalit Rozbalit vše Re: Debian Postfix + Fail2ban - ignoruje host.deny i iptables
Po vyčištění do původního stavu:

# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination
fail2ban-apache-badbots  all  --  anywhere             anywhere
fail2ban-postfix  all  --  anywhere             anywhere
fail2ban-apache  all  --  anywhere             anywhere
fail2ban-apache-myadmin  all  --  anywhere             anywhere
fail2ban-apache-w00tw00t  all  --  anywhere             anywhere
fail2ban-php-url-fopen  all  --  anywhere             anywhere
fail2ban-apache-nohome  all  --  anywhere             anywhere
fail2ban-webmin  all  --  anywhere             anywhere
fail2ban-dovecot  all  --  anywhere             anywhere
fail2ban-pure-ftpd  all  --  anywhere             anywhere
fail2ban-apache-overflows  all  --  anywhere             anywhere
fail2ban-apache-noscript  all  --  anywhere             anywhere
fail2ban-ssh-ddos  all  --  anywhere             anywhere
fail2ban-pam-generic  all  --  anywhere             anywhere
fail2ban-ssh  all  --  anywhere             anywhere

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Chain fail2ban-apache (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-apache-badbots (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-apache-myadmin (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-apache-nohome (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-apache-noscript (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-apache-overflows (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-apache-w00tw00t (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-dovecot (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-pam-generic (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-php-url-fopen (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-postfix (1 references)
target     prot opt source               destination
DROP       all  --  208.73.211.164       anywhere
DROP       all  --  208.73.211.177       anywhere
DROP       all  --  208.73.211.249       anywhere
DROP       all  --  208.73.211.236       anywhere
DROP       all  --  208.73.211.182       anywhere
RETURN     all  --  anywhere             anywhere

Chain fail2ban-pure-ftpd (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-ssh (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-ssh-ddos (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

Chain fail2ban-webmin (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere
AraxoN avatar 2.4.2014 09:16 AraxoN | skóre: 47 | blog: slon_v_porcelane | Košice
Rozbalit Rozbalit vše Re: Debian Postfix + Fail2ban - ignoruje host.deny i iptables
Hmm, to vyzerá OK... a napriek tomu Ti tam chodia z tých IP adries, ktoré tam sú uvedené ako DROP?
2.4.2014 11:51 Daves
Rozbalit Rozbalit vše Re: Debian Postfix + Fail2ban - ignoruje host.deny i iptables
Ano.

Vidím v logu z těch adres requesty a fail2ban na to reaguje hláškou "already banned".

U všeho ostatního to funguje, jen u postfixu ne. Našel jsem zmínku o tom, že postfix nemá implementovány TCP wrappers. Pokud by to byla pravda a dobře to chápu, pak by tedy iptables i host.deny ignoroval. Odpovídalo by to tomu, co se děje.

Proto se ptám, zda má někdo fail2ban+postfix funkční. Případně jak to řeší.
AraxoN avatar 2.4.2014 13:49 AraxoN | skóre: 47 | blog: slon_v_porcelane | Košice
Rozbalit Rozbalit vše Re: Debian Postfix + Fail2ban - ignoruje host.deny i iptables
TCP wrappers používajú /etc/hosts.allow a hosts.deny. Je to zastaralý a neefektívny spôsob a je asi dobre, že ho postfix nepodporuje. Iptables pracuje na úrovni jadra a mal by zabezpečiť, že ku postfix-u tieto packety ani nedoputujú. Že to v Tvojom prípade nefunguje je pre mňa záhada. Musí poradiť niekto skúsenejší.
2.4.2014 13:58 1john2 | skóre: 35 | blog: jo12hn | zlín, brno
Rozbalit Rozbalit vše Re: Debian Postfix + Fail2ban - ignoruje host.deny i iptables
Odpovědět | | Sbalit | Link | Blokovat | Admin
Chain INPUT (policy ACCEPT), neni problem v tom?

pokud vim pri accept se pravidla vubec nevyhodnocuji, resp nakonci po pruchodu vsemi pravidly je ACCEPT propusti.

Zkuste nastavit policy DROP
pavlix avatar 2.4.2014 14:55 pavlix | skóre: 54 | blog: pavlix
Rozbalit Rozbalit vše Re: Debian Postfix + Fail2ban - ignoruje host.deny i iptables
pokud vim pri accept se pravidla vubec nevyhodnocuji
Nesmysl.
Zkuste nastavit policy DROP
Bohatě stačí na konci obecné pravidlo REJECT/DROP.
Já už tu vlastně ani nejsem. Abclinuxu umřelo.
2.4.2014 16:04 bigBRAMBOR | skóre: 37
Rozbalit Rozbalit vše Re: Debian Postfix + Fail2ban - ignoruje host.deny i iptables
nemuzes prece vykopirovat pul věty a napsat na ni ze je to nesmysl, veta nezacnula dobre, ale v druhe pulce to vyjasnuje a má to dobre.

..., resp nakonci po pruchodu vsemi pravidly je ACCEPT propusti.
2.4.2014 20:56 Daves
Rozbalit Rozbalit vše Re: Debian Postfix + Fail2ban - ignoruje host.deny i iptables
Zkuste nastavit policy DROP
Neznamená to náhodou opačnou funkci ? Odmítnou vše krom ACCEPT v pravidlech ?

Pro SSH a FTP to funguje dobře. Jeden ban a útrum. Jen u toho postfixu je nějaký problém.

Založit nové vláknoNahoru

Tiskni Sdílej: Linkuj Jaggni to Vybrali.sme.sk Google Del.icio.us Facebook

ISSN 1214-1267, (c) 1999-2007 Stickfish s.r.o.