linuxserver / docker-fail2ban

GNU General Public License v3.0
42 stars 7 forks source link

[BUG] Error: No chain/target/match by that name #12

Closed mtrolley closed 9 months ago

mtrolley commented 1 year ago

Is there an existing issue for this?

Current Behavior

I set up my jail.local to ban failed login attempts to my LSIO openssh-server by adding this:

[openssh-server]
enabled = true
chain   = DOCKER-USER
action  = %(known/action)s
port    = 2223,2222
logpath = %(remote_logs_path)s/openssh-server/openssh/current
filter  = sshd[mode=aggressive]

When a brute force attempt was detected fail2ban tried to block the IP but the log shows it failed:

 2023-03-29 16:40:14,776 7FF1A26E8B38 ERROR 7ff1a352d890 -- exec: { iptables -w -C f2b-openssh-server -j RETURN >/dev/null 2>&1; } || { iptables -w -N f2b-openssh-server || true; iptables -w -A f2b-openssh-server -j RETURN; }
 2023-03-29 16:40:14,776 7FF1A26E8B38 ERROR 7ff1a352d890 -- stderr: 'iptables: No chain/target/match by that name.'
 2023-03-29 16:40:14,776 7FF1A26E8B38 ERROR 7ff1a352d890 -- returned 1
 2023-03-29 16:40:14,776 7FF1A26E8B38 ERROR Failed to execute ban jail 'openssh-server' action 'iptables-multiport' info 'ActionInfo({'ip': '167.71.38.232', 'family': 'inet4', 'fid': <function Actions.ActionInfo.<lambda> at 0x7ff1a3ec09d0>, 'raw-ticket': <function Actions.ActionInfo.<lambda> at 0x7ff1a3ec1090>})': Error starting action Jail('openssh-server')/iptables-multiport: 'Script error'

If I run the first command listed with exec manually when logged into the container as root it succeeds though:

root@fail2ban:/# { iptables -w -C f2b-openssh-server -j RETURN >/dev/null 2>&1; } || { iptables -w -N f2b-openssh-server || true; iptables -w -A f2b-openssh-server -j RETURN; }
root@fail2ban:/#

Then on the host:

❯ sudo iptables-legacy -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-N f2b-openssh-server
-A f2b-openssh-server -j RETURN

Expected Behavior

The command should succeed to ban the IP.

Steps To Reproduce

Set up fail2ban container with jail.local like:

[DEFAULT]

action   = %(action_)s

# Prevents banning LAN subnets
ignoreip = 127.0.0.1/8 ::1
           10.0.0.0/8
           172.16.0.0/12
           192.168.0.0/16

[sshd]
enabled = true
chain   = INPUT
action  = %(known/action)s

[openssh-server]
enabled = true
chain   = DOCKER-USER
action  = %(known/action)s
port    = 2223,2222
logpath = %(remote_logs_path)s/openssh-server/openssh/current
filter  = sshd[mode=aggressive]

[nginx-http-auth]
enabled = true
chain   = DOCKER-USER
action  = %(known/action)s

[nginx-badbots]
# configuration inherits from jail.d/nginx-badbots.conf
enabled = true
chain   = DOCKER-USER
action  = %(known/action)s

[nginx-botsearch]
# configuration inherits from jail.conf
enabled = true
chain   = DOCKER-USER
action  = %(known/action)s

[nginx-deny]
# configuration inherits from jail.d/nginx-deny.conf
enabled = true
chain   = DOCKER-USER
action  = %(known/action)s

[nginx-unauthorized]
# configuration inherits from jail.d/nginx-unauthorized.conf
enabled = true
chain   = DOCKER-USER
action  = %(known/action)s

Environment

- OS: Ubuntu 22.04.2 
- How docker service was installed: docker-ce package with apt.

CPU architecture

x86-64

Docker creation

fail2ban:
    cap_add:
    - NET_ADMIN
    - NET_RAW
    container_name: fail2ban
    environment:
      PGID: "1000"
      PUID: "1000"
      TZ: US/Eastern
    image: lscr.io/linuxserver/fail2ban
    logging:
      driver: json-file
      options:
        max-file: "10"
        max-size: 200k
    network_mode: host
    restart: unless-stopped
    volumes:
    - type: bind
      source: /etc/localtime
      target: /etc/localtime
      read_only: true
      bind:
        create_host_path: true
    - type: bind
      source: /var/log
      target: /var/log
      read_only: true
      bind:
        create_host_path: true
    - type: bind
      source: /home/trolley/.config/appdata/fail2ban
      target: /config
      bind:
        create_host_path: true
    - type: bind
      source: /home/trolley/.config/appdata/openssh-server/logs
      target: /remotelogs/openssh-server
      bind:
        create_host_path: true

Container logs

[migrations] started
[migrations] no migrations found
usermod: failed to copy the lastlog entry of user 911 to user 1000: Read-only file system
usermod: failed to copy the faillog entry of user 911 to user 1000: Read-only file system
───────────────────────────────────────

      ██╗     ███████╗██╗ ██████╗ 
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝ 

   Brought to you by linuxserver.io
───────────────────────────────────────

To support LSIO projects visit:
https://www.linuxserver.io/donate/

───────────────────────────────────────
GID/UID
───────────────────────────────────────

User UID:    1000
User GID:    1000
───────────────────────────────────────

[custom-init] No custom files found, skipping...
[ls.io-init] done.
 2023-03-29 16:40:12,897 7FF1A4D0DB48 INFO  Loading configs for fail2ban under /etc/fail2ban 
 2023-03-29 16:40:12,897 7FF1A4D0DB48 DEBUG Reading configs for fail2ban under /etc/fail2ban 
 2023-03-29 16:40:12,897 7FF1A4D0DB48 DEBUG Reading config files: /etc/fail2ban/fail2ban.conf
 2023-03-29 16:40:12,897 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/fail2ban.conf']
 2023-03-29 16:40:12,898 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/fail2ban.conf']
 2023-03-29 16:40:12,898 7FF1A4D0DB48 INFO  Using socket file /var/run/fail2ban/fail2ban.sock
 2023-03-29 16:40:12,898 7FF1A4D0DB48 INFO  Using pid file /var/run/fail2ban/fail2ban.pid, [INFO] logging to /config/log/fail2ban/fail2ban.log
 2023-03-29 16:40:12,898 7FF1A4D0DB48 INFO  Loading configs for jail under /etc/fail2ban 
 2023-03-29 16:40:12,899 7FF1A4D0DB48 DEBUG Reading configs for jail under /etc/fail2ban 
 2023-03-29 16:40:12,899 7FF1A4D0DB48 DEBUG Reading config files: /etc/fail2ban/jail.conf, /etc/fail2ban/jail.d/airsonic-auth.conf, /etc/fail2ban/jail.d/apache-auth.conf, /etc/fail2ban/jail.d/apache-badbots.conf, /etc/fail2ban/jail.d/apache-botsearch.conf, /etc/fail2ban/jail.d/apache-fakegooglebot.conf, /etc/fail2ban/jail.d/apache-modsecurity.conf, /etc/fail2ban/jail.d/apache-nohome.conf, /etc/fail2ban/jail.d/apache-noscript.conf, /etc/fail2ban/jail.d/apache-overflows.conf, /etc/fail2ban/jail.d/apache-shellshock.conf, /etc/fail2ban/jail.d/authelia-auth.conf, /etc/fail2ban/jail.d/bitwarden.conf, /etc/fail2ban/jail.d/dropbear.conf, /etc/fail2ban/jail.d/emby-auth.conf, /etc/fail2ban/jail.d/filebrowser-auth.conf, /etc/fail2ban/jail.d/gitea-auth.conf, /etc/fail2ban/jail.d/gitlab.conf, /etc/fail2ban/jail.d/grafana.conf, /etc/fail2ban/jail.d/guacamole.conf, /etc/fail2ban/jail.d/haproxy-http-auth.conf, /etc/fail2ban/jail.d/homeassistant-auth.conf, /etc/fail2ban/jail.d/lighttpd-auth.conf, /etc/fail2ban/jail.d/nextcloud-auth.conf, /etc/fail2ban/jail.d/nginx-418.conf, /etc/fail2ban/jail.d/nginx-bad-request.conf, /etc/fail2ban/jail.d/nginx-badbots.conf, /etc/fail2ban/jail.d/nginx-botsearch.conf, /etc/fail2ban/jail.d/nginx-deny.conf, /etc/fail2ban/jail.d/nginx-http-auth.conf, /etc/fail2ban/jail.d/nginx-limit-req.conf, /etc/fail2ban/jail.d/nginx-unauthorized.conf, /etc/fail2ban/jail.d/nzbget-auth.conf, /etc/fail2ban/jail.d/openhab-auth.conf, /etc/fail2ban/jail.d/overseerr-auth.conf, /etc/fail2ban/jail.d/php-url-fopen.conf, /etc/fail2ban/jail.d/phpmyadmin-syslog.conf, /etc/fail2ban/jail.d/prowlarr-auth.conf, /etc/fail2ban/jail.d/radarr-auth.conf, /etc/fail2ban/jail.d/sabnzbd-auth.conf, /etc/fail2ban/jail.d/selinux-ssh.conf, /etc/fail2ban/jail.d/sonarr-auth.conf, /etc/fail2ban/jail.d/sshd.conf, /etc/fail2ban/jail.d/suhosin.conf, /etc/fail2ban/jail.d/traefik-auth.conf, /etc/fail2ban/jail.d/unifi-controller-auth.conf, /etc/fail2ban/jail.d/unraid-sshd.conf, /etc/fail2ban/jail.d/unraid-webgui.conf, /etc/fail2ban/jail.d/vaultwarden-auth.conf, /etc/fail2ban/jail.d/znc-adminlog.conf, /etc/fail2ban/jail.d/zoneminder.conf, /etc/fail2ban/jail.local
 2023-03-29 16:40:12,899 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.conf']
 2023-03-29 16:40:12,900 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/paths-lsio.conf']
 2023-03-29 16:40:12,900 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/paths-common.conf']
 2023-03-29 16:40:12,901 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/paths-overrides.local']
 2023-03-29 16:40:12,901 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/airsonic-auth.conf']
 2023-03-29 16:40:12,901 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/apache-auth.conf']
 2023-03-29 16:40:12,901 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/apache-badbots.conf']
 2023-03-29 16:40:12,902 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/apache-botsearch.conf']
 2023-03-29 16:40:12,902 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/apache-fakegooglebot.conf']
 2023-03-29 16:40:12,902 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/apache-modsecurity.conf']
 2023-03-29 16:40:12,902 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/apache-nohome.conf']
 2023-03-29 16:40:12,902 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/apache-noscript.conf']
 2023-03-29 16:40:12,903 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/apache-overflows.conf']
 2023-03-29 16:40:12,903 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/apache-shellshock.conf']
 2023-03-29 16:40:12,903 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/authelia-auth.conf']
 2023-03-29 16:40:12,903 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/bitwarden.conf']
 2023-03-29 16:40:12,903 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/dropbear.conf']
 2023-03-29 16:40:12,904 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/emby-auth.conf']
 2023-03-29 16:40:12,904 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/filebrowser-auth.conf']
 2023-03-29 16:40:12,904 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/gitea-auth.conf']
 2023-03-29 16:40:12,904 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/gitlab.conf']
 2023-03-29 16:40:12,904 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/grafana.conf']
 2023-03-29 16:40:12,905 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/guacamole.conf']
 2023-03-29 16:40:12,905 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/haproxy-http-auth.conf']
 2023-03-29 16:40:12,905 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/homeassistant-auth.conf']
 2023-03-29 16:40:12,905 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/lighttpd-auth.conf']
 2023-03-29 16:40:12,905 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/nextcloud-auth.conf']
 2023-03-29 16:40:12,905 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/nginx-418.conf']
 2023-03-29 16:40:12,906 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/nginx-bad-request.conf']
 2023-03-29 16:40:12,906 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/nginx-badbots.conf']
 2023-03-29 16:40:12,906 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/nginx-botsearch.conf']
 2023-03-29 16:40:12,907 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/nginx-deny.conf']
 2023-03-29 16:40:12,907 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/nginx-http-auth.conf']
 2023-03-29 16:40:12,907 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/nginx-limit-req.conf']
 2023-03-29 16:40:12,907 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/nginx-unauthorized.conf']
 2023-03-29 16:40:12,907 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/nzbget-auth.conf']
 2023-03-29 16:40:12,908 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/openhab-auth.conf']
 2023-03-29 16:40:12,908 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/overseerr-auth.conf']
 2023-03-29 16:40:12,908 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/php-url-fopen.conf']
 2023-03-29 16:40:12,908 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/phpmyadmin-syslog.conf']
 2023-03-29 16:40:12,908 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/prowlarr-auth.conf']
 2023-03-29 16:40:12,909 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/radarr-auth.conf']
 2023-03-29 16:40:12,909 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/sabnzbd-auth.conf']
 2023-03-29 16:40:12,909 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/selinux-ssh.conf']
 2023-03-29 16:40:12,909 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/sonarr-auth.conf']
 2023-03-29 16:40:12,909 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/sshd.conf']
 2023-03-29 16:40:12,910 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/suhosin.conf']
 2023-03-29 16:40:12,910 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/traefik-auth.conf']
 2023-03-29 16:40:12,910 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/unifi-controller-auth.conf']
 2023-03-29 16:40:12,910 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/unraid-sshd.conf']
 2023-03-29 16:40:12,910 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/unraid-webgui.conf']
 2023-03-29 16:40:12,911 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/vaultwarden-auth.conf']
 2023-03-29 16:40:12,911 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/znc-adminlog.conf']
 2023-03-29 16:40:12,911 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.d/zoneminder.conf']
 2023-03-29 16:40:12,911 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/jail.local']
 2023-03-29 16:40:12,912 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/paths-common.conf', '/etc/fail2ban/paths-lsio.conf', '/etc/fail2ban/jail.conf', '/etc/fail2ban/jail.d/airsonic-auth.conf', '/etc/fail2ban/jail.d/apache-auth.conf', '/etc/fail2ban/jail.d/apache-badbots.conf', '/etc/fail2ban/jail.d/apache-botsearch.conf', '/etc/fail2ban/jail.d/apache-fakegooglebot.conf', '/etc/fail2ban/jail.d/apache-modsecurity.conf', '/etc/fail2ban/jail.d/apache-nohome.conf', '/etc/fail2ban/jail.d/apache-noscript.conf', '/etc/fail2ban/jail.d/apache-overflows.conf', '/etc/fail2ban/jail.d/apache-shellshock.conf', '/etc/fail2ban/jail.d/authelia-auth.conf', '/etc/fail2ban/jail.d/bitwarden.conf', '/etc/fail2ban/jail.d/dropbear.conf', '/etc/fail2ban/jail.d/emby-auth.conf', '/etc/fail2ban/jail.d/filebrowser-auth.conf', '/etc/fail2ban/jail.d/gitea-auth.conf', '/etc/fail2ban/jail.d/gitlab.conf', '/etc/fail2ban/jail.d/grafana.conf', '/etc/fail2ban/jail.d/guacamole.conf', '/etc/fail2ban/jail.d/haproxy-http-auth.conf', '/etc/fail2ban/jail.d/homeassistant-auth.conf', '/etc/fail2ban/jail.d/lighttpd-auth.conf', '/etc/fail2ban/jail.d/nextcloud-auth.conf', '/etc/fail2ban/jail.d/nginx-418.conf', '/etc/fail2ban/jail.d/nginx-bad-request.conf', '/etc/fail2ban/jail.d/nginx-badbots.conf', '/etc/fail2ban/jail.d/nginx-botsearch.conf', '/etc/fail2ban/jail.d/nginx-deny.conf', '/etc/fail2ban/jail.d/nginx-http-auth.conf', '/etc/fail2ban/jail.d/nginx-limit-req.conf', '/etc/fail2ban/jail.d/nginx-unauthorized.conf', '/etc/fail2ban/jail.d/nzbget-auth.conf', '/etc/fail2ban/jail.d/openhab-auth.conf', '/etc/fail2ban/jail.d/overseerr-auth.conf', '/etc/fail2ban/jail.d/php-url-fopen.conf', '/etc/fail2ban/jail.d/phpmyadmin-syslog.conf', '/etc/fail2ban/jail.d/prowlarr-auth.conf', '/etc/fail2ban/jail.d/radarr-auth.conf', '/etc/fail2ban/jail.d/sabnzbd-auth.conf', '/etc/fail2ban/jail.d/selinux-ssh.conf', '/etc/fail2ban/jail.d/sonarr-auth.conf', '/etc/fail2ban/jail.d/sshd.conf', '/etc/fail2ban/jail.d/suhosin.conf', '/etc/fail2ban/jail.d/traefik-auth.conf', '/etc/fail2ban/jail.d/unifi-controller-auth.conf', '/etc/fail2ban/jail.d/unraid-sshd.conf', '/etc/fail2ban/jail.d/unraid-webgui.conf', '/etc/fail2ban/jail.d/vaultwarden-auth.conf', '/etc/fail2ban/jail.d/znc-adminlog.conf', '/etc/fail2ban/jail.d/zoneminder.conf', '/etc/fail2ban/jail.local']
 2023-03-29 16:40:12,912 7FF1A4D0DB48 WARNI 'allowipv6' not defined in 'Definition'. Using default one: 'auto'
 2023-03-29 16:40:12,913 7FF1A4D0DB48 INFO  Loading configs for filter.d/apache-badbots under /etc/fail2ban 
 2023-03-29 16:40:12,913 7FF1A4D0DB48 DEBUG Reading configs for filter.d/apache-badbots under /etc/fail2ban 
 2023-03-29 16:40:12,913 7FF1A4D0DB48 DEBUG Reading config files: /etc/fail2ban/filter.d/apache-badbots.conf
 2023-03-29 16:40:12,913 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/apache-badbots.conf']
 2023-03-29 16:40:12,913 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/apache-badbots.conf']
 2023-03-29 16:40:12,914 7FF1A4D0DB48 INFO  Loading configs for action.d/iptables-multiport under /etc/fail2ban 
 2023-03-29 16:40:12,914 7FF1A4D0DB48 DEBUG Reading configs for action.d/iptables-multiport under /etc/fail2ban 
 2023-03-29 16:40:12,914 7FF1A4D0DB48 DEBUG Reading config files: /etc/fail2ban/action.d/iptables-multiport.conf
 2023-03-29 16:40:12,914 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/action.d/iptables-multiport.conf']
 2023-03-29 16:40:12,915 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/action.d/iptables.conf']
 2023-03-29 16:40:12,915 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/action.d/iptables.conf', '/etc/fail2ban/action.d/iptables-multiport.conf']
 2023-03-29 16:40:12,915 7FF1A4D0DB48 INFO  Loading configs for action.d/discord-webhook under /etc/fail2ban 
 2023-03-29 16:40:12,916 7FF1A4D0DB48 DEBUG Reading configs for action.d/discord-webhook under /etc/fail2ban 
 2023-03-29 16:40:12,916 7FF1A4D0DB48 DEBUG Reading config files: /etc/fail2ban/action.d/discord-webhook.conf
 2023-03-29 16:40:12,916 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/action.d/discord-webhook.conf']
 2023-03-29 16:40:12,916 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/action.d/discord-webhook.conf']
 2023-03-29 16:40:12,916 7FF1A4D0DB48 INFO  Loading configs for filter.d/nginx-botsearch under /etc/fail2ban 
 2023-03-29 16:40:12,916 7FF1A4D0DB48 DEBUG Reading configs for filter.d/nginx-botsearch under /etc/fail2ban 
 2023-03-29 16:40:12,916 7FF1A4D0DB48 DEBUG Reading config files: /etc/fail2ban/filter.d/nginx-botsearch.conf
 2023-03-29 16:40:12,917 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/nginx-botsearch.conf']
 2023-03-29 16:40:12,917 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/botsearch-common.conf']
 2023-03-29 16:40:12,917 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/botsearch-common.conf', '/etc/fail2ban/filter.d/nginx-botsearch.conf']
 2023-03-29 16:40:12,918 7FF1A4D0DB48 INFO  Loading configs for filter.d/nginx-deny under /etc/fail2ban 
 2023-03-29 16:40:12,918 7FF1A4D0DB48 DEBUG Reading configs for filter.d/nginx-deny under /etc/fail2ban 
 2023-03-29 16:40:12,918 7FF1A4D0DB48 DEBUG Reading config files: /etc/fail2ban/filter.d/nginx-deny.conf
 2023-03-29 16:40:12,918 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/nginx-deny.conf']
 2023-03-29 16:40:12,919 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/common.conf']
 2023-03-29 16:40:12,919 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/common.local']
 2023-03-29 16:40:12,919 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/common.conf', '/etc/fail2ban/filter.d/nginx-deny.conf']
 2023-03-29 16:40:12,920 7FF1A4D0DB48 INFO  Loading configs for filter.d/nginx-http-auth under /etc/fail2ban 
 2023-03-29 16:40:12,920 7FF1A4D0DB48 DEBUG Reading configs for filter.d/nginx-http-auth under /etc/fail2ban 
 2023-03-29 16:40:12,920 7FF1A4D0DB48 DEBUG Reading config files: /etc/fail2ban/filter.d/nginx-http-auth.conf
 2023-03-29 16:40:12,921 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/nginx-http-auth.conf']
 2023-03-29 16:40:12,921 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/nginx-http-auth.conf']
 2023-03-29 16:40:12,922 7FF1A4D0DB48 INFO  Loading configs for filter.d/nginx-unauthorized under /etc/fail2ban 
 2023-03-29 16:40:12,922 7FF1A4D0DB48 DEBUG Reading configs for filter.d/nginx-unauthorized under /etc/fail2ban 
 2023-03-29 16:40:12,922 7FF1A4D0DB48 DEBUG Reading config files: /etc/fail2ban/filter.d/nginx-unauthorized.conf
 2023-03-29 16:40:12,922 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/nginx-unauthorized.conf']
 2023-03-29 16:40:12,922 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/common.conf', '/etc/fail2ban/filter.d/nginx-unauthorized.conf']
 2023-03-29 16:40:12,924 7FF1A4D0DB48 INFO  Loading configs for filter.d/sshd under /etc/fail2ban 
 2023-03-29 16:40:12,924 7FF1A4D0DB48 DEBUG Reading configs for filter.d/sshd under /etc/fail2ban 
 2023-03-29 16:40:12,924 7FF1A4D0DB48 DEBUG Reading config files: /etc/fail2ban/filter.d/sshd.conf
 2023-03-29 16:40:12,924 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/sshd.conf']
 2023-03-29 16:40:12,925 7FF1A4D0DB48 INFO    Loading files: ['/etc/fail2ban/filter.d/common.conf', '/etc/fail2ban/filter.d/sshd.conf']
 2023-03-29 16:40:12,935 7FF1A4D0DB48 DEBUG   direct starting of server in 132, deamon: False
Server ready
github-actions[bot] commented 1 year ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

sambartik commented 1 year ago

I think it might be because the docker fail2ban uses the legacy version of iptables. You can verify that there is no f2b entries when checking iptables -L, whereas iptables-legacy -L shows the f2b's entries. The iptables-legacy in fact did not have any of the docker chains.

mtrolley commented 1 year ago

Hi @sambartik, sorry I'm not super familiar with iptables or fail2ban. Are you asking me to try something, or suggesting a possible cause for the problem?

sambartik commented 1 year ago

Hey there, Trolley. I was trying to provide more information to help resolve this issue, but unfortunately, I am not that familiar with iptables or fail2ban as well.

dgrzjohn commented 1 year ago

I am having the same issue. Setting chain = FORWARD seems to drop requests properly. The DOCKER-USER chain does exist on the host.

2023-05-06 16:16:57,149 7FB8FA9B20 ERROR 7fba20b4c0 -- exec: { iptables -w -C f2b-nginx-deny -j RETURN >/dev/null 2>&1; } || { iptables -w -N f2b-nginx-deny || true; iptables -w -A f2b-nginx-deny -j RETURN; }
for proto in $(echo 'tcp' | sed 's/,/ /g'); do
{ iptables -w -C DOCKER-USER -p $proto -m multiport --dports http,https -j f2b-nginx-deny >/dev/null 2>&1; } || { iptables -w -I DOCKER-USER -p $proto -m multiport --dports http,https -j f2b-nginx-deny; }
done
 2023-05-06 16:16:57,150 7FB8FA9B20 ERROR 7fba20b4c0 -- stderr: 'iptables: No chain/target/match by that name.'
 2023-05-06 16:16:57,150 7FB8FA9B20 ERROR 7fba20b4c0 -- returned 1
 2023-05-06 16:16:57,151 7FB8FA9B20 ERROR Failed to execute ban jail 'nginx-deny' action 'iptables-multiport' info 'ActionInfo({'ip': 'x.x.x.x', 'family': 'inet4', 'fid': <function Actions.ActionInfo.<lambda> at 0x7fba1988b0>, 'raw-ticket': <function Actions.ActionInfo.<lambda> at 0x7fba198f70>})': Error starting action Jail('nginx-deny')/iptables-multiport: 'Script error'
mtrolley commented 1 year ago

I gave up on this container but copied the filter and jail config files to the Ubuntu host to run fail2ban directly on the host and it works there.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

silmarine commented 1 year ago

This is also not working for me. I am currently just using the route action that sets an unknown route for the banned IP and that works but it totally bans the IP instead of just that IP on the application/port number.

github-actions[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not had recent activity. This might be due to missing feedback from OP. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] commented 8 months ago

This issue is locked due to inactivity