Hallo,
ich habe den ssh Zugang eines Servers mit fail2ban abgesichert. Der Server ist auch via ipv6 erreichbar.
Wenn fail2ban nach n Fehlversuchen eine ip per iptables sperrt, dann ist das für ipv4 OK. Allerdings würde ich gerne bei ipv6 das ganze 64er oder 56er Subnetz sperren. Denn dem Client steht vermutlich ein ganzes Subnetz zur Verfügung und er kann einfach eine neue ipv6-Adresse generieren und so den iptabels REJECT umgehen.
Nun ist die ipv6 Integration in fail2ban ziemlich neu (seit Version 0.10) und die Dokumentation bezüglich ipv6 noch äußerst spärlich.

Bei Debian wird für die sshd Jail /etc/fail2ban/action.d/iptables-multiport.conf eingebunden.

Für ipv6 habe ich die defaults für actionban und actionunban überschrieben und einfach den <ip> Platzhalter um das Subnetz erweitert.
<iptables> wird durch /etc/fail2ban/action.d/iptables-common.conf automatich zu ip6tables verändert.

Code:
# Fail2Ban configuration file
#
# Author: Cyril Jaquier
# Modified by Yaroslav Halchenko for multiport banning
#

[INCLUDES]

before = iptables-common.conf

[Definition]

# Option:  actionstart
# Notes.:  command executed once at the start of Fail2Ban.
# Values:  CMD
#
actionstart = <iptables> -N f2b-<name>
              <iptables> -A f2b-<name> -j <returntype>
              <iptables> -I <chain> -p <protocol> -m multiport --dports <port> -j f2b-<name>

# Option:  actionstop
# Notes.:  command executed once at the end of Fail2Ban
# Values:  CMD
#
actionstop = <iptables> -D <chain> -p <protocol> -m multiport --dports <port> -j f2b-<name>
             <actionflush>
             <iptables> -X f2b-<name>

# Option:  actioncheck
# Notes.:  command executed once before each actionban command
# Values:  CMD
#
actioncheck = <iptables> -n -L <chain> | grep -q 'f2b-<name>[ \t]'

# Option:  actionban
# Notes.:  command executed when banning an IP. Take care that the
#          command is executed with Fail2Ban user rights.
# Tags:    See jail.conf(5) man page
# Values:  CMD
#
actionban = <iptables> -I f2b-<name> 1 -s <ip> -j <blocktype>

# Option:  actionunban
# Notes.:  command executed when unbanning an IP. Take care that the
#          command is executed with Fail2Ban user rights.
# Tags:    See jail.conf(5) man page
# Values:  CMD
#
actionunban = <iptables> -D f2b-<name> -s <ip> -j <blocktype>

[Init]
[Init?family=inet6]
actionban = <iptables> -I f2b-<name> 1 -s <ip>\/64 -j <blocktype>
actionunban = <iptables> -D f2b-<name> -s <ip>\/64 -j <blocktype>
Das ganze scheint so (stabil?) zu laufen.
Die Lösung erscheint mir aber fast zu einfach. Bis ich diese simple Lösung hatte, habe ich zunächst versucht eine eigene jail (abgeleitet aus dummy.conf ( dediziert für ipv6 zu erstellen. Dann werden die Logs aber zweimal geparst, die vorgenannte Lösung sollte daher effizienter sein.

Blockt jemand von Euch ipv6 Sutbnezte mit fail2ban und kann bestätigen, dass die Veränderung von actionban und actionunban dafür ausreichend und sicher ist?
Hat jemand Lust dies auch einmal zu testen?
Gibt es für Version 0.10 eine andere default Methode um Subnezte zu blockieren?

Einen Stolperstein gibt es. Beim Aufruf von fail2ban-client set JAIL banip|unbanip IP muss stets die ganze Adresse angegeben werden, nur das Subnetz reicht nicht aus. Es scheint, dass die volle Adresse in der SQLite Datei hinterlegt zu sein.

Gruß
craano