avenga
Goto Top

Fail2ban Docker kann iptables nicht setzen

Hallo, ich habe fail2ban als Container auf Unraid 7 installiert, genauer gesagt "lscr.io/linuxserver/fail2ban" um Nginx Proxy Manager abzusichern.
Den ersten Teil habe ich erfogreich hin bekommen, er möchte gern bannen aber iptables will nicht.

Meine jail.local:
[DEFAULT]
bantime  = 4h
maxretry = 3

[npm]
enabled = true
port 	= 12345
backend = polling
logpath = /var/log/proxy-host-*_error.log
chain   = DOCKER-USER
action  = %(known/action)s

Habe mich an der Readme orientiert

Sowohl IPv4 als auch IPv6 klappt nicht:

2025-03-16 15:05:59,104 146D00D56B38 INFO  [npm] Found 2003:da:xxx - 2025-03-16 15:05:58
 2025-03-16 15:06:02,336 146D00D56B38 INFO  [npm] Found 2003:da:xxx - 2025-03-16 15:06:01
 2025-03-16 15:06:09,597 146D00D56B38 INFO  [npm] Found 2003:da:xxx - 2025-03-16 15:06:09
 2025-03-16 15:06:10,344 146D00B4BB38 NOTIC [npm] Ban 2003:da:xxx
 2025-03-16 15:06:10,379 146D00B4BB38 ERROR 146d01b796f0 -- exec: { ip6tables -w -C f2b-npm -j RETURN >/dev/null 2>&1; } || { ip6tables -w -N f2b-npm || true; ip6tables -w -A f2b-npm -j RETURN; }
for proto in $(echo 'tcp' | sed 's/,/ /g'); do  
{ ip6tables -w -C DOCKER-USER -p $proto -m multiport --dports 12345 -j f2b-npm >/dev/null 2>&1; } || { ip6tables -w -I DOCKER-USER -p $proto -m multiport --dports 12345 -j f2b-npm; }
done
 2025-03-16 15:06:10,381 146D00B4BB38 ERROR 146d01b796f0 -- stderr: 'ip6tables: No chain/target/match by that name.'  
 2025-03-16 15:06:10,382 146D00B4BB38 ERROR 146d01b796f0 -- returned 1
 2025-03-16 15:06:10,383 146D00B4BB38 ERROR Failed to execute ban jail 'npm' action 'iptables-multiport' info 'ActionInfo({'ip': '2003:da:xxx', 'family': 'inet6', 'fid': <function Actions.ActionInfo.<lambda> at 0x146d01b85a80>, 'raw-ticket': <function Actions.ActionInfo.<lambda> at 0x146d01b86200>})': Error starting action Jail('npm')/iptables-multiport: 'Script error'  

das gleiche bei IPv4:
2025-03-16 15:12:25,087 146D00D56B38 INFO  [npm] Found 80.187.xxx - 2025-03-16 15:12:24
 2025-03-16 15:12:43,834 146D00D56B38 INFO  [npm] Found 80.187.xxx - 2025-03-16 15:12:43
 2025-03-16 15:12:49,078 146D00D56B38 INFO  [npm] Found 80.187.xxx - 2025-03-16 15:12:49
 2025-03-16 15:12:49,177 146D00B4BB38 NOTIC [npm] Ban 80.187.xxx
 2025-03-16 15:12:49,195 146D00B4BB38 ERROR 146d01b5fd20 -- exec: { iptables -w -C f2b-npm -j RETURN >/dev/null 2>&1; } || { iptables -w -N f2b-npm || true; iptables -w -A f2b-npm -j RETURN; }
for proto in $(echo 'tcp' | sed 's/,/ /g'); do  
{ iptables -w -C DOCKER-USER -p $proto -m multiport --dports 12345 -j f2b-npm >/dev/null 2>&1; } || { iptables -w -I DOCKER-USER -p $proto -m multiport --dports 12345 -j f2b-npm; }
done
 2025-03-16 15:12:49,196 146D00B4BB38 ERROR 146d01b5fd20 -- stderr: 'iptables: No chain/target/match by that name.'  
 2025-03-16 15:12:49,196 146D00B4BB38 ERROR 146d01b5fd20 -- returned 1
 2025-03-16 15:12:49,196 146D00B4BB38 ERROR Failed to execute ban jail 'npm' action 'iptables-multiport' info 'ActionInfo({'ip': '80.187.xxx', 'family': 'inet4', 'fid': <function Actions.ActionInfo.<lambda> at 0x146d01b85a80>, 'raw-ticket': <function Actions.ActionInfo.<lambda> at 0x146d01b86200>})': Error starting action Jail('npm')/iptables-multiport: 'Script error'  

Fail2Ban läuft im Host Modus mit priv. Rechten.
NPM läuft im Bridge Modus.

Jemand eine Idee warum fail2ban keine iptables erstellen kann oder darf ?

Content-ID: 671979

Url: https://administrator.de/forum/fail2ban-docker-kann-iptables-nicht-setzen-671979.html

Ausgedruckt am: 17.03.2025 um 02:03 Uhr

aqui
aqui 16.03.2025 um 21:06:29 Uhr
Goto Top
Moderne Distros (Debian etc.) haben nftables aktiv und nicht mehr die veralteten iptables. Hast du das mal überprüft mit systemctl status iptables oder systemctl status nftables ?
Sollte das bei dir ebenfalls der Fall sein muss du in der jail.local die Default "banaction" entsprechend umstellen.
Sollte keiner der beiden Firewall Prozesse laufen musst du einen davon natürlich vorab aktivieren.
Avenga
Avenga 16.03.2025 aktualisiert um 21:15:49 Uhr
Goto Top
root@Unraid:~# iptables --version
iptables v1.8.11 (legacy)
root@Unraid:~# ip6tables --version
ip6tables v1.8.11 (legacy)
root@Unraid:~# nft --version
bash: nft: command not found
root@Unraid:~# 
systemctl kennt Unraid nicht.. ist kein Debian face-confused

Nichtsdestotrotz sollte iptables mit fai2ban funktionieren, wenn der Docker extra für Unraid gebaut wurde.

die f2b-npm chain konnte ich zumindest per Hand einpflegen:
Chain f2b-npm (0 references)
target     prot opt source               destination         
RETURN     all  --  anywhere             anywhere      
dann sollte es der priviligierte Docker auch können dachte ich zumindest.
aqui
aqui 16.03.2025 aktualisiert um 21:25:17 Uhr
Goto Top
systemctl kennt Unraid nicht.. ist kein Debian
Mmmhhh, das hat nix mit Debian zu tun, das ist ein SystemD Kommando was so gut wie alle Distros nutzen. Ungewöhnlich...
Nichtsdestotrotz sollte iptables mit fai2ban funktionieren
Nur wenn die Default banaction, wie oben schon gesagt, auf iptables gesetzt ist.
Bei modernen Distros ist es nftables.
banaction = nftables-multiport
banaction_allports = nftables-allports