fail2ban bzw. iptables: Nur IPs werden gebannt (keine Hostnamen)

  • Thread starter Thread starter Deleted member 11625
  • Start date Start date
D

Deleted member 11625

Guest
Ich habe auf meinem Server (Debian 7.6 x64) fail2ban installiert und habe es so konfiguriert, dass z. B. nach zwei Falscheingaben des SSH-Logins für 24h gesperrt wird. Ich möchte eigentlich (und dachte, dass es so eingestellt sei), dass die entsprechende IP dann keinerlei Zugriff mehr auf den Server hat. Dem ist leider nicht so. Hier zunächst mal eine Ausgabe von iptables -vL --line-numbers zum besseren Verständnis:

Code:
Chain INPUT (policy DROP 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination
3      36M 5550M fail2ban-ssh  tcp  --  any    any     anywhere             anywhere

Und weiter unten:

Code:
Chain fail2ban-ssh (1 references)
num   pkts bytes target     prot opt in     out     source               destination
1      156  8038 REJECT     all  --  any    any     pxxxxxxxx.dip0.t-ipconnect.de  anywhere             reject-with icmp-port-unreachable
2      36M 5550M RETURN     all  --  any    any     anywhere             anywhere

Für mich sieht es eigentlich so aus, als würde jede Anfrage, egal welches Ziel, egal welches Protokoll, abgeblockt. Das gilt zwar für die IP-Adressen (habe mehrere), aber ich kann noch wunderbar per Domainname auf meine Websites zugreifen, nachdem ich gebannt wurde. Mailabruf geht auch und ein Ping geht sogar mit der IP.

Warum? Verstehe ich iptables nicht oder geht das einfach nicht?

Ich bin eigentlich sicher, dass es damals unter Debian 6.x anders war und dort wirklich alles geblockt wurde.
 
Da deine Ausgabe mit Zeile 3 beginnt, liegt es Nahe, dass du nur die Hälfte gepostet hast. fail2ban kann nicht zaubern. Wenn da andere Regel zuvor den Traffic erlauben, kannst du in fail2ban soviel blocken wie du willst.

Poste bitte die vollständige Ausgabe von "iptables -L -n -v".
 
Die zwei Zeilen darüber sind meiner Meinung nach irrelevant, aber hier sind sie (sind ebenfalls fail2ban-Einträge):

Code:
1      57M 9157M fail2ban-plesk-apache-badbot  tcp  --  any    any     anywhere             anywhere
2      57M 9158M fail2ban-plesk-panel  tcp  --  any    any     anywhere             anywhere

Ist das darunter auch relevant? Letztendlich werde ich ja geblockt, aber nur teilweise. Dadurch, dass ich z. B. per SSH gar nicht mehr drauf komme, gehe ich davon aus, dass es keine Anweisung geben kann, die den Zugriff im Nachhinein wieder erlaubt.
 
Last edited by a moderator:
Wenn ich sage alles, dann meine ich auch alles. Und nicht den nächsten gekürzten Auszug. :rolleyes:

Ausgehend von dem bisher geposteten, kann es keine teilweise Blockierung geben. Wenn Verbindungen per IP geblockt werden, Verbindung via Domainnamen aber nicht, liegt die Vermutung nahe, dass die Domain auf einen völlig anderen Server zeigt.

Wenn du mehr als Mutmaßungen und Vermutungen haben willst, liefer bitte die vollständige Ausgabe, sowie die IP und die Domain mit der testest. Dann können wir auch probieren es zu reproduzieren.
 
Hier nun alles (wobei ich mir erlaubt habe, aus Datenschutzgründen innerhalb der fail2ban-Chains die aktuell gesperrten Einträge zu entfernen):

Code:
Chain INPUT (policy DROP 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1      57M 9173M fail2ban-plesk-apache-badbot  tcp  --  any    any     anywhere             anywhere            
2      57M 9174M fail2ban-plesk-panel  tcp  --  any    any     anywhere             anywhere            
3      57M 9176M fail2ban-ssh  tcp  --  any    any     anywhere             anywhere            
4     101M   63G fail2ban-plesk-horde  tcp  --  any    any     anywhere             anywhere            
5     101M   63G fail2ban-plesk-dovecot  tcp  --  any    any     anywhere             anywhere            
6     101M   63G fail2ban-plesk-postfix  tcp  --  any    any     anywhere             anywhere            
7     101M   63G fail2ban-plesk-proftpd  tcp  --  any    any     anywhere             anywhere            
8     100M   63G fail2ban-recidive  tcp  --  any    any     anywhere             anywhere            
9      59M 9895M ACCEPT     all  --  any    any     anywhere             anywhere             state RELATED,ESTABLISHED
10   10798 3444K REJECT     tcp  --  any    any     anywhere             anywhere             tcpflags:! FIN,SYN,RST,ACK/SYN state NEW reject-with tcp-reset
11    454K   21M DROP       all  --  any    any     anywhere             anywhere             state INVALID
12   58060 3484K ACCEPT     all  --  lo     any     anywhere             anywhere            
13     441 23980 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpts:49152:49171
14     225 11700 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:29781
15      22  1144 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:58566
16       0     0 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:12443
17       0     0 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:11443
18       0     0 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:11444
19       0     0 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:8447
20      77  3480 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:8443
21       5   240 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:8880
22   1837K  103M ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:http
23   1439K   80M ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:https
24     706 33920 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:ftp
25    7289  306K ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:ssh
26     646 33332 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:submission
27    1651 84544 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:smtp
28     100  5088 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:ssmtp
29     420 21124 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:pop3
30     411 21528 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:pop3s
31     308 15764 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:imap2
32      84  4392 ACCEPT     tcp  --  any    any     anywhere             anywhere             tcp dpt:imaps
33      10   400 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:poppassd
34       0     0 ACCEPT     tcp  --  any    any     localhost            anywhere             tcp dpt:mysql
35      23   920 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:postgresql
36       0     0 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:9008
37       5   248 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:9080
38    268K   21M DROP       udp  --  any    any     anywhere             anywhere             udp dpt:netbios-ns
39    320K   72M DROP       udp  --  any    any     anywhere             anywhere             udp dpt:netbios-dgm
40     133  6544 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:netbios-ssn
41    5169  253K DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:microsoft-ds
42       0     0 DROP       udp  --  any    any     anywhere             anywhere             udp dpt:openvpn
43     956 62996 DROP       udp  --  any    any     anywhere             anywhere             udp dpt:domain
44     238 10192 DROP       tcp  --  any    any     anywhere             anywhere             tcp dpt:domain
45    5646  393K ACCEPT     icmp --  any    any     anywhere             anywhere             icmptype 8 code 0
46   7005K 3166M DROP       all  --  any    any     anywhere             anywhere            

Chain FORWARD (policy DROP 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1        0     0 ACCEPT     all  --  any    any     anywhere             anywhere             state RELATED,ESTABLISHED
2        0     0 REJECT     tcp  --  any    any     anywhere             anywhere             tcpflags:! FIN,SYN,RST,ACK/SYN state NEW reject-with tcp-reset
3        0     0 DROP       all  --  any    any     anywhere             anywhere             state INVALID
4        0     0 ACCEPT     all  --  lo     lo      anywhere             anywhere            
5        0     0 DROP       all  --  any    any     anywhere             anywhere            

Chain OUTPUT (policy DROP 0 packets, 0 bytes)
num   pkts bytes target     prot opt in     out     source               destination         
1      41M   90G ACCEPT     all  --  any    any     anywhere             anywhere             state RELATED,ESTABLISHED
2     4884 1186K REJECT     tcp  --  any    any     anywhere             anywhere             tcpflags:! FIN,SYN,RST,ACK/SYN state NEW reject-with tcp-reset
3     4785  260K DROP       all  --  any    any     anywhere             anywhere             state INVALID
4    58060 3484K ACCEPT     all  --  any    lo      anywhere             anywhere            
5     687K   50M ACCEPT     all  --  any    any     anywhere             anywhere            

Chain fail2ban-plesk-apache-badbot (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
12     57M 9173M RETURN     all  --  any    any     anywhere             anywhere            

Chain fail2ban-plesk-dovecot (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
3     101M   63G RETURN     all  --  any    any     anywhere             anywhere            

Chain fail2ban-plesk-horde (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
1     101M   63G RETURN     all  --  any    any     anywhere             anywhere            

Chain fail2ban-plesk-panel (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
1      57M 9174M RETURN     all  --  any    any     anywhere             anywhere            

Chain fail2ban-plesk-postfix (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
5     101M   63G RETURN     all  --  any    any     anywhere             anywhere            

Chain fail2ban-plesk-proftpd (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
19    100M   63G RETURN     all  --  any    any     anywhere             anywhere            

Chain fail2ban-recidive (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
1     100M   63G RETURN     all  --  any    any     anywhere             anywhere            

Chain fail2ban-ssh (1 references)
num   pkts bytes target     prot opt in     out     source               destination         
1      57M 9176M RETURN     all  --  any    any     anywhere             anywhere

So kann's getestet werden:

FTP "81.7.15.202" => 3x Passwort falsch eingeben, Zugriff über IP wird gesperrt, aber die zugehörige Domain "af-forum.de" geht noch! Kannst ja vorher mal über die IP die Website aufrufen, da geht's noch.
 
Last edited by a moderator:
Code:
# host af-forum.de
af-forum.de has address 81.7.15.202
af-forum.de has IPv6 address 2a02:180:1:1::5b8f:513e
af-forum.de mail is handled by 10 af-forum.de.

# curl af-forum.de
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.amateurfilm-forum.de/">here</a>.</p>
<hr>
<address>Apache Server at af-forum.de Port 80</address>
</body></html>

# ftp af-forum.de
Connected to af-forum.de.
220 ProFTPD 1.3.5 Server (ProFTPD) [81.7.15.202]
Name (af-forum.de:root): ssftest
331 Password required for ssftest
Password:
530 Login incorrect.
Login failed.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quit
221 Goodbye.

# ftp af-forum.de
Connected to af-forum.de.
220 ProFTPD 1.3.5 Server (ProFTPD) [81.7.15.202]
Name (af-forum.de:root): ssftest
331 Password required for ssftest
Password:
530 Login incorrect.
Login failed.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quit
221 Goodbye.

# ftp af-forum.de
Connected to af-forum.de.
220 ProFTPD 1.3.5 Server (ProFTPD) [81.7.15.202]
Name (af-forum.de:root): ssftest
331 Password required for ssftest
Password:
530 Login incorrect.
Login failed.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quit

# curl af-forum.de
curl: (7) Failed to connect to 2a02:180:1:1::5b8f:513e: Network is unreachable

Funktioniert doch alles wie es soll. Deine Domain löst aber auch auf eine IPv6 Adresse auf.
IPv4 und IPv6 haben unterschiedlichen IPTables. Siehe "ip6tables -L -n -v". ;)

Wenn du deine IPv4 Adresse sperren lässt und dann über die IPv6 Adresse weiterarbeitest funktioniert das selbstverständlich weiter. Fail2Ban kann ja schlecht die IPv6 Adressen des Clients erraten, der via IPv4 Blödsinn betreibt.

Edit:
Mein Test-Host von eben hat keine IPv6 Adresse. Da er via IPv4 nicht mehr durfte hat er es via IPv6 probiert, kam dann aber wegen der eigenen Gegebenheiten nicht weit. Daher von der Fehlermeldung nicht zu sehr irritieren lassen. ;)
 
Argh! Natürlich, das ist es! Ich greife per IPv6 auf meine Websites zu, daher gehen die Hostnamen noch. Also ist ja alles in Butter!

Da hatte ich überhaupt nicht dran gedacht. Also sorry für den unnötigen Thread. ;)

Danke!
 
Back
Top