Um den Port von FHEM gegen Brute-Force-Angriffe abzusichern, habe ich eine Regel für fail2ban geschrieben. Anbei eine kurze Anleitung dazu. Nach 10 erfolglosen Anmeldeversuchen wird der User per iptables für 1 Tag (86400 Sekunden) geblockt.
1. sudo apt install fail2ban (fail2ban installieren)
2. sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local (eigene Konfiguration erstellen)
3. Filter in neuer Datei erstellen: /etc/fail2ban/filter.d/fhem.conf
# Fail2ban filter for fhem
[INCLUDES]
before = common.conf
[Definition]
failregex = ^(.*?)Login denied (.*?)_<HOST>_
ignoreregex =
4. Eigenes jail in der Datei /etc/fail2ban/jail.local anfügen. Dabei den richtigen Port und den Pfad zum Log-Verzeichnis eintragen.
[fhem]
enabled = true
port = 8083
action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp]
%(mta)s-whois[name=%(__name__)s, dest="%(destemail)s"]
filter = fhem
logpath = /opt/fhem/log/fhem-20*
maxretry = 10
bantime = 86400
5. /etc/init.d/fail2ban restart ausführen
6. allowed-Instanz auf Loglevel 3 stellen attr allowed_WEB verbose 3
7. cronjob erstellencat <(crontab -l) <(sudo echo "1 0 1 * * /bin/systemctl restart fail2ban") | crontab -
Gruß Jens
Du solltest vielleicht erwähnen das Deine Konfig ausschließlich mit einem aktuellen FHEM funktioniert. Update > 17.02.2018
Wann benutzt man denn fail2ban in Verbindung mit FHEM? Doch nur wenn man FHEM direkt am Inet hängen hat, oder?
4. Eigenes jail in /etc/fail2ban/jail.local anfügen.
[fhem]
enabled = true
port = 8083
action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp]
%(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp]
%(mta)s-whois[name=%(__name__)s, dest="%(destemail)s"]
filter = fhem
logpath = /opt/fhem/log/fhem-20*
maxretry = 10
bantime = 86400
Wenn du schreibst "anfügen", dann fehlt ja folgender Code in der Liste:
# Fail2ban filter for fhem
[INCLUDES]
before = common.conf
[Definition]
failregex = ^(.*?)Login denied by (.*?)_<HOST>_
ignoreregex =
Oder meintest du "ersetzen" ??
Gruß
Tom
Habe die Beschreibung etwas konkretisiert.
Hab das ganze jetzt mal so eingerichtet wie du es geschrieben hast.
Leider passiert nicht viel wenn ich versuche mich ein Dutzend mal mit falschem Passwort anzumelden.
Es wird nichts geblockt und ich kann mich danach ganz normal anmelden. :-\
Missglückte Anmeldungen vom lokalen Netzwerk werden per default ignoriert (sh. ignoreip in jail.local).
Versuche es mal von außen.
Gruß Jens
Zitat von: dirigent am 18 Februar 2018, 17:29:40
Missglückte Anmeldungen vom lokalen Netzwerk werden per default ignoriert (sh. ignoreip in jail.local).
Versuche es mal von außen.
Gruß Jens
Das habe ich getan!
Laut Log funktioniert alles, aber wie ich bereits erwähnt habe komme ich immer noch rein in FHEM mit der geblockten IP.
The IP 81.169.xxx.xxx has just been banned by Fail2Ban after
3 attempts against fhem.\n\n
Here are more information about 81.169.xxx.xxx:\n
`/usr/bin/whois 81.169.xxx.xxx`\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
Was sagt denn "fail2ban-client status fhem" und "iptables -S" sowie "/var/log/fail2ban.log"?
Ist der richtige Port eingetragen?
Was meinst du mit "fail2ban-client status fhem"?
iptables -S
-P INPUT ACCEPT
-P FORWARD ACCEPT
-P OUTPUT ACCEPT
-N fail2ban-fhem-udp
-N fail2ban-ip-blacklist
-N fail2ban-ssh
-A INPUT -p tcp -j fail2ban-ip-blacklist
-A INPUT -p udp -m multiport --dports 8083 -j fail2ban-fhem-udp
-A INPUT -p tcp -m multiport --dports 22 -j fail2ban-ssh
-A fail2ban-fhem-udp -s 81.169.xxx.xxx/32 -j DROP
-A fail2ban-fhem-udp -j RETURN
-A fail2ban-ip-blacklist -j RETURN
-A fail2ban-ssh -j RETURN
/var/log/fail2ban.log
2018-02-18 15:46:43,852 fail2ban.server : INFO Changed logging target to /var/log/fail2ban.log for Fail2ban v0.8.6
2018-02-18 15:46:43,855 fail2ban.jail : INFO Creating new jail 'ssh'
2018-02-18 15:46:43,856 fail2ban.jail : INFO Jail 'ssh' uses poller
2018-02-18 15:46:43,923 fail2ban.filter : INFO Added logfile = /var/log/auth.log
2018-02-18 15:46:43,926 fail2ban.filter : INFO Set maxRetry = 6
2018-02-18 15:46:43,930 fail2ban.filter : INFO Set findtime = 600
2018-02-18 15:46:43,932 fail2ban.actions: INFO Set banTime = 600
2018-02-18 15:46:44,129 fail2ban.jail : INFO Jail 'ssh' started
2018-02-18 16:15:33,525 fail2ban.server : INFO Stopping all jails
2018-02-18 16:15:34,256 fail2ban.jail : INFO Jail 'ssh' stopped
2018-02-18 16:15:34,258 fail2ban.server : INFO Exiting Fail2ban
2018-02-18 16:15:46,815 fail2ban.server : INFO Changed logging target to /var/log/fail2ban.log for Fail2ban v0.8.6
2018-02-18 16:15:46,818 fail2ban.jail : INFO Creating new jail 'ssh'
2018-02-18 16:15:46,829 fail2ban.jail : INFO Jail 'ssh' uses Gamin
2018-02-18 16:15:46,980 fail2ban.filter : INFO Added logfile = /var/log/auth.log
2018-02-18 16:15:46,983 fail2ban.filter : INFO Set maxRetry = 6
2018-02-18 16:15:46,987 fail2ban.filter : INFO Set findtime = 600
2018-02-18 16:15:46,989 fail2ban.actions: INFO Set banTime = 600
2018-02-18 16:15:47,179 fail2ban.jail : INFO Creating new jail 'fhem'
2018-02-18 16:15:47,180 fail2ban.jail : INFO Jail 'fhem' uses Gamin
2018-02-18 16:15:47,188 fail2ban.filter : INFO Added logfile = /opt/fhem/log/fhem-2018-02.log
2018-02-18 16:15:47,191 fail2ban.filter : INFO Set maxRetry = 10
2018-02-18 16:15:47,196 fail2ban.filter : INFO Set findtime = 600
2018-02-18 16:15:47,199 fail2ban.actions: INFO Set banTime = 86400
2018-02-18 16:15:47,272 fail2ban.jail : INFO Creating new jail 'ip-blacklist'
2018-02-18 16:15:47,273 fail2ban.jail : INFO Jail 'ip-blacklist' uses Gamin
2018-02-18 16:15:47,278 fail2ban.filter : INFO Added logfile = /etc/fail2ban/ip.blacklist
2018-02-18 16:15:47,280 fail2ban.filter : INFO Set maxRetry = 0
2018-02-18 16:15:47,283 fail2ban.filter : INFO Set findtime = 15552000
2018-02-18 16:15:47,285 fail2ban.actions: INFO Set banTime = -1
2018-02-18 16:15:47,326 fail2ban.jail : INFO Jail 'ssh' started
2018-02-18 16:15:47,373 fail2ban.jail : INFO Jail 'fhem' started
2018-02-18 16:15:47,404 fail2ban.jail : INFO Jail 'ip-blacklist' started
2018-02-18 16:15:47,504 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: started
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The jail fhem has been started successfully.\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 17:04:18,686 fail2ban.actions: WARNING [fhem] Ban 81.169.xxx.xxx
2018-02-18 17:04:18,837 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: banned 81.169.xxx.xxx
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The IP 81.169.xxx.xxx has just been banned by Fail2Ban after
11 attempts against fhem.\n\n
Here are more information about 81.169.xxx.xxx:\n
`/usr/bin/whois 81.169.xxx.xxx`\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 17:15:18,549 fail2ban.server : INFO Stopping all jails
2018-02-18 17:15:18,667 fail2ban.actions: WARNING [fhem] Unban 81.169.xxx.xxx
2018-02-18 17:15:18,728 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: stopped
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The jail fhem has been stopped.\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 17:15:19,187 fail2ban.jail : INFO Jail 'fhem' stopped
2018-02-18 17:15:20,158 fail2ban.jail : INFO Jail 'ip-blacklist' stopped
2018-02-18 17:15:20,564 fail2ban.jail : INFO Jail 'ssh' stopped
2018-02-18 17:15:20,576 fail2ban.server : INFO Exiting Fail2ban
2018-02-18 17:15:31,029 fail2ban.server : INFO Changed logging target to /var/log/fail2ban.log for Fail2ban v0.8.6
2018-02-18 17:15:31,032 fail2ban.jail : INFO Creating new jail 'ssh'
2018-02-18 17:15:31,044 fail2ban.jail : INFO Jail 'ssh' uses Gamin
2018-02-18 17:15:31,207 fail2ban.filter : INFO Added logfile = /var/log/auth.log
2018-02-18 17:15:31,210 fail2ban.filter : INFO Set maxRetry = 6
2018-02-18 17:15:31,214 fail2ban.filter : INFO Set findtime = 600
2018-02-18 17:15:31,217 fail2ban.actions: INFO Set banTime = 600
2018-02-18 17:15:31,417 fail2ban.jail : INFO Creating new jail 'fhem'
2018-02-18 17:15:31,418 fail2ban.jail : INFO Jail 'fhem' uses Gamin
2018-02-18 17:15:31,424 fail2ban.filter : INFO Added logfile = /opt/fhem/log/fhem-2018-02.log
2018-02-18 17:15:31,427 fail2ban.filter : INFO Set maxRetry = 10
2018-02-18 17:15:31,432 fail2ban.filter : INFO Set findtime = 600
2018-02-18 17:15:31,435 fail2ban.actions: INFO Set banTime = 86400
2018-02-18 17:15:31,509 fail2ban.jail : INFO Creating new jail 'ip-blacklist'
2018-02-18 17:15:31,510 fail2ban.jail : INFO Jail 'ip-blacklist' uses Gamin
2018-02-18 17:15:31,515 fail2ban.filter : INFO Added logfile = /etc/fail2ban/ip.blacklist
2018-02-18 17:15:31,517 fail2ban.filter : INFO Set maxRetry = 0
2018-02-18 17:15:31,520 fail2ban.filter : INFO Set findtime = 15552000
2018-02-18 17:15:31,522 fail2ban.actions: INFO Set banTime = -1
2018-02-18 17:15:31,554 fail2ban.jail : INFO Jail 'ssh' started
2018-02-18 17:15:31,610 fail2ban.jail : INFO Jail 'fhem' started
2018-02-18 17:15:31,692 fail2ban.jail : INFO Jail 'ip-blacklist' started
2018-02-18 17:15:31,721 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: started
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The jail fhem has been started successfully.\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:02:43,002 fail2ban.actions: WARNING [fhem] Ban 81.169.xxx.xxx
2018-02-18 19:02:43,116 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: banned 81.169.xxx.xxx
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The IP 81.169.xxx.xxx has just been banned by Fail2Ban after
10 attempts against fhem.\n\n
Here are more information about 81.169.xxx.xxx:\n
`/usr/bin/whois 81.169.xxx.xxx`\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:16:48,176 fail2ban.actions: WARNING [fhem] Ban 77.182.xx.xx
2018-02-18 19:16:48,288 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: banned 77.182.xx.xx
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The IP 77.182.xx.xx has just been banned by Fail2Ban after
10 attempts against fhem.\n\n
Here are more information about 77.182.xx.xx:\n
`/usr/bin/whois 77.182.xx.xx`\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:19:21,901 fail2ban.server : INFO Stopping all jails
2018-02-18 19:19:22,474 fail2ban.actions: WARNING [fhem] Unban 81.169.xxx.xxx
2018-02-18 19:19:22,500 fail2ban.actions: WARNING [fhem] Unban 77.182.xx.xx
2018-02-18 19:19:22,561 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: stopped
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The jail fhem has been stopped.\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:19:22,562 fail2ban.jail : INFO Jail 'fhem' stopped
2018-02-18 19:19:23,426 fail2ban.jail : INFO Jail 'ip-blacklist' stopped
2018-02-18 19:19:24,339 fail2ban.jail : INFO Jail 'ssh' stopped
2018-02-18 19:19:24,344 fail2ban.server : INFO Exiting Fail2ban
2018-02-18 19:19:34,338 fail2ban.server : INFO Changed logging target to /var/log/fail2ban.log for Fail2ban v0.8.6
2018-02-18 19:19:34,342 fail2ban.jail : INFO Creating new jail 'ssh'
2018-02-18 19:19:34,354 fail2ban.jail : INFO Jail 'ssh' uses Gamin
2018-02-18 19:19:34,502 fail2ban.filter : INFO Added logfile = /var/log/auth.log
2018-02-18 19:19:34,505 fail2ban.filter : INFO Set maxRetry = 6
2018-02-18 19:19:34,509 fail2ban.filter : INFO Set findtime = 600
2018-02-18 19:19:34,511 fail2ban.actions: INFO Set banTime = 600
2018-02-18 19:19:34,700 fail2ban.jail : INFO Creating new jail 'fhem'
2018-02-18 19:19:34,700 fail2ban.jail : INFO Jail 'fhem' uses Gamin
2018-02-18 19:19:34,706 fail2ban.filter : INFO Added logfile = /opt/fhem/log/fhem-2018-02.log
2018-02-18 19:19:34,709 fail2ban.filter : INFO Set maxRetry = 2
2018-02-18 19:19:34,713 fail2ban.filter : INFO Set findtime = 600
2018-02-18 19:19:34,715 fail2ban.actions: INFO Set banTime = 86400
2018-02-18 19:19:34,774 fail2ban.jail : INFO Creating new jail 'ip-blacklist'
2018-02-18 19:19:34,775 fail2ban.jail : INFO Jail 'ip-blacklist' uses Gamin
2018-02-18 19:19:34,780 fail2ban.filter : INFO Added logfile = /etc/fail2ban/ip.blacklist
2018-02-18 19:19:34,783 fail2ban.filter : INFO Set maxRetry = 0
2018-02-18 19:19:34,787 fail2ban.filter : INFO Set findtime = 15552000
2018-02-18 19:19:34,789 fail2ban.actions: INFO Set banTime = -1
2018-02-18 19:19:34,834 fail2ban.jail : INFO Jail 'ssh' started
2018-02-18 19:19:34,945 fail2ban.jail : INFO Jail 'fhem' started
2018-02-18 19:19:34,973 fail2ban.jail : INFO Jail 'ip-blacklist' started
2018-02-18 19:19:35,002 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: started
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The jail fhem has been started successfully.\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:19:37,015 fail2ban.actions: WARNING [fhem] Ban 77.182.xx.xx
2018-02-18 19:19:37,145 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: banned 77.182.xx.xx
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The IP 77.182.xx.xx has just been banned by Fail2Ban after
11 attempts against fhem.\n\n
Here are more information about 77.182.xx.xx:\n
`/usr/bin/whois 77.182.xx.xx`\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:20:39,265 fail2ban.actions: WARNING [fhem] Ban 81.169.xxx.xxx
2018-02-18 19:20:39,383 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: banned 81.169.xxx.xxx
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The IP 81.169.xxx.xxx has just been banned by Fail2Ban after
2 attempts against fhem.\n\n
Here are more information about 81.169.xxx.xxx:\n
`/usr/bin/whois 81.169.xxx.xxx`\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:20:42,389 fail2ban.actions: WARNING [fhem] 81.169.xxx.xxx already banned
2018-02-18 19:31:26,531 fail2ban.server : INFO Stopping all jails
2018-02-18 19:31:27,211 fail2ban.actions: WARNING [fhem] Unban 77.182.xx.xx
2018-02-18 19:31:27,235 fail2ban.actions: WARNING [fhem] Unban 81.169.xxx.xxx
2018-02-18 19:31:27,304 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: stopped
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The jail fhem has been stopped.\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:31:27,306 fail2ban.jail : INFO Jail 'fhem' stopped
2018-02-18 19:31:28,008 fail2ban.jail : INFO Jail 'ip-blacklist' stopped
2018-02-18 19:31:28,901 fail2ban.jail : INFO Jail 'ssh' stopped
2018-02-18 19:31:28,910 fail2ban.server : INFO Changed logging target to /var/log/fail2ban.log for Fail2ban v0.8.6
2018-02-18 19:31:28,914 fail2ban.jail : INFO Creating new jail 'ssh'
2018-02-18 19:31:28,915 fail2ban.jail : INFO Jail 'ssh' uses Gamin
2018-02-18 19:31:28,922 fail2ban.filter : INFO Added logfile = /var/log/auth.log
2018-02-18 19:31:28,926 fail2ban.filter : INFO Set maxRetry = 2
2018-02-18 19:31:28,932 fail2ban.filter : INFO Set findtime = 600
2018-02-18 19:31:28,936 fail2ban.actions: INFO Set banTime = 600
2018-02-18 19:31:29,032 fail2ban.jail : INFO Creating new jail 'fhem'
2018-02-18 19:31:29,033 fail2ban.jail : INFO Jail 'fhem' uses Gamin
2018-02-18 19:31:29,038 fail2ban.filter : INFO Added logfile = /opt/fhem/log/fhem-2018-02.log
2018-02-18 19:31:29,040 fail2ban.filter : INFO Set maxRetry = 2
2018-02-18 19:31:29,043 fail2ban.filter : INFO Set findtime = 600
2018-02-18 19:31:29,045 fail2ban.actions: INFO Set banTime = 86400
2018-02-18 19:31:29,089 fail2ban.jail : INFO Creating new jail 'ip-blacklist'
2018-02-18 19:31:29,089 fail2ban.jail : INFO Jail 'ip-blacklist' uses Gamin
2018-02-18 19:31:29,093 fail2ban.filter : INFO Added logfile = /etc/fail2ban/ip.blacklist
2018-02-18 19:31:29,095 fail2ban.filter : INFO Set maxRetry = 0
2018-02-18 19:31:29,098 fail2ban.filter : INFO Set findtime = 15552000
2018-02-18 19:31:29,100 fail2ban.actions: INFO Set banTime = -1
2018-02-18 19:31:29,134 fail2ban.jail : INFO Jail 'ssh' started
2018-02-18 19:31:29,172 fail2ban.jail : INFO Jail 'fhem' started
2018-02-18 19:31:29,250 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: started
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The jail fhem has been started successfully.\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:31:29,262 fail2ban.jail : INFO Jail 'ip-blacklist' started
2018-02-18 19:35:54,582 fail2ban.actions: WARNING [fhem] Ban 81.169.xxx.xxx
2018-02-18 19:35:54,703 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: banned 81.169.xxx.xxx
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The IP 81.169.xxx.xxx has just been banned by Fail2Ban after
3 attempts against fhem.\n\n
Here are more information about 81.169.xxx.xxx:\n
`/usr/bin/whois 81.169.xxx.xxx`\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:47:45,193 fail2ban.server : INFO Stopping all jails
2018-02-18 19:47:45,585 fail2ban.actions: WARNING [fhem] Unban 81.169.xxx.xxx
2018-02-18 19:47:45,647 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: stopped
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The jail fhem has been stopped.\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:47:45,648 fail2ban.jail : INFO Jail 'fhem' stopped
2018-02-18 19:47:46,488 fail2ban.jail : INFO Jail 'ip-blacklist' stopped
2018-02-18 19:47:47,418 fail2ban.jail : INFO Jail 'ssh' stopped
2018-02-18 19:47:47,427 fail2ban.server : INFO Changed logging target to /var/log/fail2ban.log for Fail2ban v0.8.6
2018-02-18 19:47:47,431 fail2ban.jail : INFO Creating new jail 'ssh'
2018-02-18 19:47:47,432 fail2ban.jail : INFO Jail 'ssh' uses Gamin
2018-02-18 19:47:47,441 fail2ban.filter : INFO Added logfile = /var/log/auth.log
2018-02-18 19:47:47,446 fail2ban.filter : INFO Set maxRetry = 2
2018-02-18 19:47:47,459 fail2ban.filter : INFO Set findtime = 600
2018-02-18 19:47:47,464 fail2ban.actions: INFO Set banTime = 600
2018-02-18 19:47:47,573 fail2ban.jail : INFO Creating new jail 'fhem'
2018-02-18 19:47:47,574 fail2ban.jail : INFO Jail 'fhem' uses Gamin
2018-02-18 19:47:47,578 fail2ban.filter : INFO Added logfile = /opt/fhem/log/fhem-2018-02.log
2018-02-18 19:47:47,580 fail2ban.filter : INFO Set maxRetry = 2
2018-02-18 19:47:47,588 fail2ban.filter : INFO Set findtime = 600
2018-02-18 19:47:47,590 fail2ban.actions: INFO Set banTime = 86400
2018-02-18 19:47:47,646 fail2ban.jail : INFO Creating new jail 'ip-blacklist'
2018-02-18 19:47:47,646 fail2ban.jail : INFO Jail 'ip-blacklist' uses Gamin
2018-02-18 19:47:47,650 fail2ban.filter : INFO Added logfile = /etc/fail2ban/ip.blacklist
2018-02-18 19:47:47,653 fail2ban.filter : INFO Set maxRetry = 0
2018-02-18 19:47:47,660 fail2ban.filter : INFO Set findtime = 15552000
2018-02-18 19:47:47,663 fail2ban.actions: INFO Set banTime = -1
2018-02-18 19:47:47,696 fail2ban.jail : INFO Jail 'ssh' started
2018-02-18 19:47:47,716 fail2ban.jail : INFO Jail 'fhem' started
2018-02-18 19:47:47,757 fail2ban.jail : INFO Jail 'ip-blacklist' started
2018-02-18 19:47:47,825 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: started
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The jail fhem has been started successfully.\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:48:12,866 fail2ban.actions: WARNING [fhem] Ban 81.169.xxx.xxx
2018-02-18 19:48:12,956 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: banned 81.169.xxx.xxx
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The IP 81.169.xxx.xxx has just been banned by Fail2Ban after
3 attempts against fhem.\n\n
Here are more information about 81.169.xxx.xxx:\n
`/usr/bin/whois 81.169.xxx.xxx`\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-18 19:48:15,961 fail2ban.actions: WARNING [fhem] 81.169.xxx.xxx already banned
klappt doch super. Er blockt zu mindestens. Ok falsches Protokoll, udp statt tcp, aber immer hin.
Zitat von: CoolTux am 18 Februar 2018, 20:23:56
klappt doch super. Er blockt zu mindestens. Ok falsches Protokoll, udp statt tcp, aber immer hin.
Gar nichts blockt er,.... was ist falsch und wo muss ich was ändern?
Natürlich blockt er, schau Dir doch das iptables Regelwerk an.
-N fail2ban-fhem-udp
-A INPUT -p tcp -j fail2ban-ip-blacklist
-A INPUT -p udp -m multiport --dports 8083 -j fail2ban-fhem-udp
-A fail2ban-fhem-udp -s 81.169.xxx.xxx/32 -j DROP
-A fail2ban-fhem-udp -j RETURN
-A fail2ban-ip-blacklist -j RETURN
Einzig irgend so ein Schlaumeier war der Meinung das FHEM über das udp Protokoll mit Port 8083 kommuniziert.
Hier ist übrigens Dein gebanntes IP-Subnetz
-A fail2ban-fhem-udp -s 81.169.xxx.xxx/32 -j DROP
Nimm mal den Unsinn hier raus
%(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp]
Zitat von: CoolTux am 18 Februar 2018, 20:46:39
Einzig irgend so ein Schlaumeier war der Meinung das FHEM über das udp Protokoll mit Port 8083 kommuniziert.
Hier ist übrigens Dein gebanntes IP-Subnetz
-A fail2ban-fhem-udp -s 81.169.xxx.xxx/32 -j DROP
Wenn fail2ban blockt, wieso kann ich mich dann immer noch mit der selben IP anmelden???
Zitat von: CoolTux am 18 Februar 2018, 20:46:39
Nimm mal den Unsinn hier raus
%(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp]
HA,... jetzt scheint es zu funktionieren. Dann werde ich jetzt mal weiter tüfteln,... danke für deine Hilfe! :D
Weil er nur das UDP Protokoll für die IP und den Port 8083 blockt. FHEM aber über das TCP Protokoll an kommt, HTTP/S halt.
Meinst Du nicht das wenn Du sowas verwenden möchtest Du Dich auch damit erstmal auseinander setzen musst? Was machst Du wenn Du Dich komplett ausgesperrt hast, oder einzelne Ports nicht mehr klappen von Deinen Clients aus. Da kuckst wie ein Schwein ins Uhrwerk und schreist hier im Forum bestimmt rum was das wieder für ein Mist ist.
Zitat von: CoolTux am 18 Februar 2018, 21:02:33
Weil er nur das UDP Protokoll für die IP und den Port 8083 blockt. FHEM aber über das TXP Protokoll an kommt, HTTP/S halt.
Meinst Du nicht das wenn Du sowas verwenden möchtest Du Dich auch damit erstmal auseinander setzen musst? Was machst Du wenn Du Dich komplett ausgesperrt hast, oder einzelne Ports nicht mehr klappen von Deinen Clients aus. Da kuckst wie ein Schwein ins Uhrwerk und schreist hier im Forum bestimmt rum was das wieder für ein Mist ist.
Ich setz mich ja gerade damit auseinander ..... und übrigens:
# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip = 127.0.0.1/8 192.168.xxx.xxx 192.168.xxx.xxx
Zitat von: Tom111 am 18 Februar 2018, 21:07:44
Ich setz mich ja gerade damit auseinander ..... und übrigens:
# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip = 127.0.0.1/8 192.168.xxx.xxx 192.168.xxx.xxx
Na dann
http://dozent.maruweb.de/material/tcpip.shtml
Wenn Du das durch hast sollten ja alle Fragen geklärt sein.
@CoolTux
Die UDP-Regel ist wirklich nicht notwendig, sollte aber den Aufruf der TCP-Regel nicht beeinflussen.
Im übrigen begrüße ich weiterhin deine sachlichen Kommentare.
@Tom111
Hast du eventuell einen Tippfehler in der TCP-Definition?
Gruß Jens
Zitat von: dirigent am 18 Februar 2018, 21:13:39
@CoolTux
Die UDP-Regel ist wirklich nicht notwendig, sollte aber den Aufruf der TCP-Regel nicht beeinflussen.
Im übrigen begrüße ich weiterhin deine sachlichen Kommentare.
@Tom111
Hast du eventuell einen Tippfehler in der TCP-Definition?
Gruß Jens
%(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp]
%(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp]
(banaction) scheint eine Art Variable zu sein und wenn man eine weitere Zuweisung macht so wird die erste überschieben. Daher gilt die UDP Regel wenn er zu schlägt. Da die TCP Regel von der UDP Regel überschrieben wird.
Zitat von: dirigent am 18 Februar 2018, 21:13:39
@Tom111
Hast du eventuell einen Tippfehler in der TCP-Definition?
Gruß Jens
Ich habe das genauso von dir übernommen wie du es im ersten Post geschrieben hast:
[fhem]
enabled = true
port = 8083
action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp]
%(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp]
%(mta)s-whois[name=%(__name__)s, dest="%(destemail)s"]
filter = fhem
logpath = /opt/fhem/log/fhem-20*
maxretry = 10
bantime = 86400
Oder meinst du was anderes? ???
Eventuell gibt es ein Problem mit dem Multiport auf TCP.
Füge mal unter "port = 8083" eine Zeile mit "banaction = iptables" ein.
@CoolTux
banaction ist in der Tat eine Variable und bezeichnet den Namen des Actionscripts in /etc/fail2ban/action.d/.
Für FHEMWEB ist UDP nicht nötig. Mal ab davon das es anscheinend trotz der zusätzlichen Regel funktionieren sollte so wie es sich an hört.
Testen kann also nicht schaden.
Zitat von: dirigent am 18 Februar 2018, 21:38:23
Eventuell gibt es ein Problem mit dem Multiport auf TCP.
Füge mal unter "port = 8083" eine Zeile mit "banaction = iptables" ein.
Habe ich gemacht und auch wieder ...
%(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp]
eingefügt.
Nach einem Restart passiert dann wieder nichts, d.h. IP-Adressen werden wieder nicht gebannt.
was sagt
iptables -vnL
Zitat von: CoolTux am 18 Februar 2018, 21:55:27
was sagt
iptables -vnL
pi@RasPi2 ~ $ sudo iptables -vnL
Chain INPUT (policy ACCEPT 3799 packets, 450K bytes)
pkts bytes target prot opt in out source destination
2965 385K fail2ban-ip-blacklist tcp -- * * 0.0.0.0/0 0.0.0.0/0
170 21010 fail2ban-fhem-tcp tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 8083
1021 117K fail2ban-ssh tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 22
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 3251 packets, 418K bytes)
pkts bytes target prot opt in out source destination
Chain fail2ban-fhem-tcp (1 references)
pkts bytes target prot opt in out source destination
14 704 DROP all -- * * 81.169.xxx.xxx 0.0.0.0/0
156 20306 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0
Chain fail2ban-ip-blacklist (1 references)
pkts bytes target prot opt in out source destination
2965 385K RETURN all -- * * 0.0.0.0/0 0.0.0.0/0
Chain fail2ban-ssh (1 references)
pkts bytes target prot opt in out source destination
1021 117K RETURN all -- * * 0.0.0.0/0 0.0.0.0/0
Zitat von: Tom111 am 18 Februar 2018, 21:07:44
Ich setz mich ja gerade damit auseinander ..... und übrigens:
# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip = 127.0.0.1/8 192.168.xxx.xxx 192.168.xxx.xxx
ignoreip = 127.0.0.1/8 192.168.1.2/32 192.168.1.3/32
oder
ignoreip = 127.0.0.1/8 192.168.1.0/24
Auf jeden Fall muss die Netzmaske (/24 - kompltettes Netzwerk, /32 - einzelner PC) mit angegeben werden.
Gruß Jens
PS: Heute ist für mich Feierabend.
Zitat von: dirigent am 18 Februar 2018, 22:02:06
Auf jeden Fall muss die Netzmaske (/24 - kompltettes Netzwerk, /32 - einzelner PC) mit angegeben werden.
Danke, werde ich ändern, gute Nacht, ich geh auch gleich schlafen. :)
Das blocking sollte eigentlich nun gehen. Blockt er immer noch nicht?
Zitat von: CoolTux am 18 Februar 2018, 22:05:02
Das blocking sollte eigentlich nun gehen. Blockt er immer noch nicht?
Er blockt nur wenn ich folgende Zeile weg lasse:
%(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp]
@Tom
Die UDP-Regel hatte ich aus dem Standard mitkopiert und sie wird nicht wirklich benötigt. Du kannst sie auch weglassen. Allerdings halte ich es für wichtig, dass in fail2ban das UDP- parallel zum TCP-Blocking fehlerfrei funktioniert.
Gruß Jens
Zitat von: dirigent am 19 Februar 2018, 17:23:46
@Tom
Die UDP-Regel hatte ich aus dem Standard mitkopiert und sie wird nicht wirklich benötigt. Du kannst sie auch weglassen. Allerdings halte ich es für wichtig, dass in fail2ban das UDP- parallel zum TCP-Blocking fehlerfrei funktioniert.
Gruß Jens
Ich lass diese Regel dann mal weg, scheint ja soweit super zu funktionieren. Danke nochmals für den bereitgestellten Code.
Was aber noch interessant wäre, wenn ich IP-Adressen mit einer Liste dauerhaft blockieren könnte.
Ich hab das ganze mal mit einer Blacklist versucht, (habe ich von https://github.com/sergejmueller/sergejmueller.github.io/wiki/Fail2Ban:-IP-Blacklist (https://github.com/sergejmueller/sergejmueller.github.io/wiki/Fail2Ban:-IP-Blacklist)) das funktioniert aber nicht bei/mit FHEM.
Hast du da evtl. auch eine Lösung? ;)
Gruß
Tom
Dauerhaft finde ich nicht so gut. Irgendwann bekommst du zufällig die IP zugewiesen (z.B. auf dem Handy) und wirst selbst gesperrt.
Mit der Sperre von einem Tag und einem nicht ganz so leichten Kennwort bekommt jeder Hacker oder Hacker-PC graue Haare. Auf jeden Fall sollte "bantime = -1" funktionieren.
Aber einen Versuch habe ich noch ;D.
Mir ist aufgefallen, dass bei dir "backend = Gamin" genutzt wird. Vielleicht kommt der mit der config nicht klar.
Gib mal unter "port = 8083" folgendes ein:
backend = pyinotify
Gruß Jens
Zitat von: dirigent am 19 Februar 2018, 18:12:38
Dauerhaft finde ich nicht so gut. Irgendwann bekommst du zufällig die IP zugewiesen (z.B. auf dem Handy) und wirst selbst gesperrt.
Mit der Sperre von einem Tag und einem nicht ganz so leichten Kennwort bekommt jeder Hacker oder Hacker-PC graue Haare. Auf jeden Fall sollte "bantime = -1" funktionieren.
Aber einen Versuch habe ich noch ;D.
Mir ist aufgefallen, dass bei dir "backend = Gamin" genutzt wird. Vielleicht kommt der mit der config nicht klar.
Gib mal unter "port = 8083" folgendes ein:
backend = pyinotify
Gruß Jens
Hab ich gemacht, bringt leider auch nichts. :-\
Gruß
Tom
Ich setz mal hier die komplette jail.local rein, vielleicht ist da ja irgendwo ein Fehler drin:
# Fail2Ban configuration file.
#
# This file was composed for Debian systems from the original one
# provided now under /usr/share/doc/fail2ban/examples/jail.conf
# for additional examples.
#
# To avoid merges during upgrades DO NOT MODIFY THIS FILE
# and rather provide your changes in /etc/fail2ban/jail.local
#
# Author: Yaroslav O. Halchenko <debian@onerussian.com>
#
# $Revision$
#
# The DEFAULT allows a global definition of the options. They can be overridden
# in each jail afterwards.
[DEFAULT]
# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip = 127.0.0.1/8 192.168.xxx.xxx/32 192.168.xxx.xxx/32
bantime = 86400
maxretry = 2
# "backend" specifies the backend used to get files modification. Available
# options are "gamin", "polling" and "auto".
# yoh: For some reason Debian shipped python-gamin didn't work as expected
# This issue left ToDo, so polling is default backend for now
backend = auto
#
# Destination email address used solely for the interpolations in
# jail.{conf,local} configuration files.
destemail = root@localhost
#
# ACTIONS
#
# Default banning action (e.g. iptables, iptables-new,
# iptables-multiport, shorewall, etc) It is used to define
# action_* variables. Can be overridden globally or per
# section within jail.local file
banaction = iptables-multiport
# email action. Since 0.8.1 upstream fail2ban uses sendmail
# MTA for the mailing. Change mta configuration parameter to mail
# if you want to revert to conventional 'mail'.
mta = sendmail
# Default protocol
protocol = tcp
# Specify chain where jumps would need to be added in iptables-* actions
chain = INPUT
#
# Action shortcuts. To be used to define action parameter
# The simplest action to take: ban only
action_ = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
# ban & send an e-mail with whois report to the destemail.
action_mw = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
%(mta)s-whois[name=%(__name__)s, dest="%(destemail)s", protocol="%(protocol)s", chain="%(chain)s"]
# ban & send an e-mail with whois report and relevant log lines
# to the destemail.
action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
%(mta)s-whois-lines[name=%(__name__)s, dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s"]
# Choose default action. To change, just override value of 'action' with the
# interpolation to the chosen action shortcut (e.g. action_mw, action_mwl, etc) in jail.local
# globally (section [DEFAULT]) or per specific section
action = %(action_)s
#
# JAILS
#
# Next jails corresponds to the standard configuration in Fail2ban 0.6 which
# was shipped in Debian. Enable any defined here jail by including
#
# [SECTION_NAME]
# enabled = true
#
# in /etc/fail2ban/jail.local.
#
# Optionally you may override any other parameter (e.g. banaction,
# action, port, logpath, etc) in that section within jail.local
[ssh]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 2
[dropbear]
enabled = false
port = ssh
filter = sshd
logpath = /var/log/dropbear
maxretry = 6
# Generic filter for pam. Has to be used with action which bans all ports
# such as iptables-allports, shorewall
[pam-generic]
enabled = false
# pam-generic filter can be customized to monitor specific subset of 'tty's
filter = pam-generic
# port actually must be irrelevant but lets leave it all for some possible uses
port = all
banaction = iptables-allports
port = anyport
logpath = /var/log/auth.log
maxretry = 6
[xinetd-fail]
enabled = false
filter = xinetd-fail
port = all
banaction = iptables-multiport-log
logpath = /var/log/daemon.log
maxretry = 2
[ssh-ddos]
enabled = false
port = ssh
filter = sshd-ddos
logpath = /var/log/auth.log
maxretry = 6
#
# HTTP servers
#
[apache]
enabled = false
port = http,https
filter = apache-auth
logpath = /var/log/apache*/*error.log
maxretry = 6
# default action is now multiport, so apache-multiport jail was left
# for compatibility with previous (<0.7.6-2) releases
[apache-multiport]
enabled = false
port = http,https
filter = apache-auth
logpath = /var/log/apache*/*error.log
maxretry = 6
[apache-noscript]
enabled = false
port = http,https
filter = apache-noscript
logpath = /var/log/apache*/*error.log
maxretry = 6
[apache-overflows]
enabled = false
port = http,https
filter = apache-overflows
logpath = /var/log/apache*/*error.log
maxretry = 2
#
# FTP servers
#
[vsftpd]
enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = vsftpd
logpath = /var/log/vsftpd.log
# or overwrite it in jails.local to be
# logpath = /var/log/auth.log
# if you want to rely on PAM failed login attempts
# vsftpd's failregex should match both of those formats
maxretry = 6
[proftpd]
enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = proftpd
logpath = /var/log/proftpd/proftpd.log
maxretry = 6
[pure-ftpd]
enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = pure-ftpd
logpath = /var/log/auth.log
maxretry = 6
[wuftpd]
enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = wuftpd
logpath = /var/log/auth.log
maxretry = 6
#
# Mail servers
#
[postfix]
enabled = false
port = smtp,ssmtp
filter = postfix
logpath = /var/log/mail.log
[couriersmtp]
enabled = false
port = smtp,ssmtp
filter = couriersmtp
logpath = /var/log/mail.log
#
# Mail servers authenticators: might be used for smtp,ftp,imap servers, so
# all relevant ports get banned
#
[courierauth]
enabled = false
port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter = courierlogin
logpath = /var/log/mail.log
[sasl]
enabled = false
port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter = sasl
# You might consider monitoring /var/log/mail.warn instead if you are
# running postfix since it would provide the same log lines at the
# "warn" level but overall at the smaller filesize.
logpath = /var/log/mail.log
[dovecot]
enabled = false
port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s
filter = dovecot
logpath = /var/log/mail.log
# DNS Servers
# These jails block attacks against named (bind9). By default, logging is off
# with bind9 installation. You will need something like this:
#
# logging {
# channel security_file {
# file "/var/log/named/security.log" versions 3 size 30m;
# severity dynamic;
# print-time yes;
# };
# category security {
# security_file;
# };
# };
#
# in your named.conf to provide proper logging
# !!! WARNING !!!
# Since UDP is connection-less protocol, spoofing of IP and imitation
# of illegal actions is way too simple. Thus enabling of this filter
# might provide an easy way for implementing a DoS against a chosen
# victim. See
# http://nion.modprobe.de/blog/archives/690-fail2ban-+-dns-fail.html
# Please DO NOT USE this jail unless you know what you are doing.
#[named-refused-udp]
#
#enabled = false
#port = domain,953
#protocol = udp
#filter = named-refused
#logpath = /var/log/named/security.log
[named-refused-tcp]
enabled = false
port = domain,953
protocol = tcp
filter = named-refused
logpath = /var/log/named/security.log
[fhem]
enabled = true
port = 8083
action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp]
%(mta)s-whois[name=%(__name__)s, dest="%(destemail)s"]
filter = fhem
logpath = /opt/fhem/log/fhem-20*
maxretry = 2
bantime = 86400
[ip-blacklist]
enabled = true
banaction = iptables-allports
port = anyport
filter = ip-blacklist
logpath = /etc/fail2ban/ip.blacklist
maxretry = 0
findtime = 15552000
bantime = -1
Komischerweise bekommt fail2ban alles mit und schreibt die Versuche auch ins Log,
Hi,\n
The IP 78.48.xxx.xxx has just been banned by Fail2Ban after
22 attempts against fhem.\n\n
Here are more information about 78.48.xxx.xxx:\n
`/usr/bin/whois 78.48.xxx.xxx`\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
pi@RasPi2 ~ $
Die 22 Versuche habe ich mit der eingefügten UDP Zeile gemacht!,
wenn ich die folgende Zeile entferne blockt fail2ban auch
%(banaction)s[name=%(__name__)s-udp, port="%(port)s", protocol="udp", chain="%(chain)s", actname=%(banaction)s-udp]
Danke für dein geduldiges Testen! :)
Es wird auch soweit alles richtig ausgeführt. Nur der iptables scheint nicht richtig aufgerufen zu werden - warum auch immer.
Hast du das mal probiert?
Zitat von: dirigent am 18 Februar 2018, 21:38:23
Füge mal unter "port = 8083" eine Zeile mit "banaction = iptables" ein.
Deine jail.local sieht gut aus, auch wenn ich auf [ip-blacklist] verzichtet hätte.
Die UDP-Zeile nehme ich dann aus dem Beispiel raus - nicht dass es noch andere trifft.
Gruß Jens
Zitat von: dirigent am 19 Februar 2018, 18:50:49
Danke für dein geduldiges Testen! :)
Es wird auch soweit alles richtig ausgeführt. Nur der iptables scheint nicht richtig aufgerufen zu werden - warum auch immer.
Hast du das mal probiert?
ZitatFüge mal unter "port = 8083" eine Zeile mit "banaction = iptables" ein.
hab ich gemacht, sieht jetzt so aus:Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The jail fhem has been started successfully.\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
2018-02-19 18:58:08,212 fail2ban.actions: WARNING [ip-blacklist] Ban 81.169.xxx.xxx
2018-02-19 18:58:10,164 fail2ban.actions: WARNING [fhem] Ban 185.182.xxx.xxx
2018-02-19 18:58:10,307 fail2ban.actions.action: ERROR printf %b "Subject: [Fail2Ban] fhem: banned 185.182.xxx.xxx
Date: `date -u +"%a, %d %h %Y %T +0000"`
From: Fail2Ban <fail2ban>
To: root@localhost\n
Hi,\n
The IP 185.182.xxx.xxx has just been banned by Fail2Ban after
7 attempts against fhem.\n\n
Here are more information about 185.182.xxx.xxx:\n
`/usr/bin/whois 185.182.xxx.xxx`\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f fail2ban root@localhost returned 7f00
Also wenn diese UDP-Zeile nicht unbedingt benötigt wird dann lass ich sie halt weg, es klappt ja sonst soweit.
ICH muss mich bei dir bedanken, so bin ich schon mal ein ganzes Stück sicherer unterwegs, alleine hätte ich das nicht hinbekommen! :D
Ich glaube es wurde noch nicht erwähnt:
Richtig Spaß macht fail2ban in Verbindung mit blocklist.de:
Blocklist ist ein Dienst der stundengenaue Listen mit IP-Adressen pflegt, von denen momentan "böswillige" Aktionen ausgehen. Es gibt dann Scripte, die die Listen regelmäßig runterladen und damit die eigene Firewall füttern, so dass diese IP-Addressen automatisch von der Firewall draußen gehalten werden.
Der Clou wiederum (und darum ist es gut, wenn so viele Leute wie möglich mitmachen): Es gibt fail2ban-Actions die solche "Abuser" automatisch an blocklist.de melden. Sprich: wenn eine bestimmte IP bei einem fail2ban-User auffällt und gebannt wird, dann wird die IP an blocklist.de gemeldet und in deren DB eingepflegt. Bei anderen Usern, die die Listen von blocklist.de beziehen, wird diese IP dann automatisch auch gesperrt.
Als Extra-Bonus schreibt blocklist.de auch automatisch eine Abuse-Mail an den verantwortlichen Hoster der IP, wenn man eine IP meldet.
https://www.blocklist.de/de/index.html
Zum Importieren der blocklist-Liste benutze ich das hier:
https://github.com/kubax/blocklist-with-nftables
Gott sei Dank brauch man sowas nicht wenn man den Ansatz verfolgt, alles blocken und benötigtes freischalten.
Habe noch mal eine Frage an die Profis hier :)
Ich habe Fail2Ban wie im ersten Beitrag eingerichtet. Funktioniert auch alles wunderbar, danke dafür. Nun habe ich aber das Thema, dass meine FHEM Log-Dateien monatlich erstellt werden und fail2ban liest die neu erstellte Datei nicht automatisch ein. Also zum Beispiel beim Wechsel von März auf April wird die April Datei nicht eingelesen. Erst nach einem restart von fail2ban. Ist das bei euch auch so? Überwacht fail2ban nicht den Ordner? Ich nutze als backend pyinotify.
Wie habt ihr das gelöst? Ein cronjob der fail2ban restartet ist ja auch nicht die beste Lösung oder?
Hi Profi's...
bei mir läuft es auch soweit, aber
a) gibt es zu der Frage xploderpro wegen monatlichem Wechsel Log-Datei und nötigen Neustart fail2ban eine Lösung???
b) die Hacker versuchen es m.E. auch über SSL-Protokollfehler (?!), in meiner Log tauchen z.B. regelm. russische IP's auf:
2018.05.08 02:37:03 1: FHEMWEB SSL/HTTPS error: SSL accept attempt failed error:1408F10B:SSL routines:ssl3_get_record:wrong version number (peer: 185.156.177.23)
2018.05.08 02:37:03 1: FHEMWEB SSL/HTTPS error: SSL accept attempt failed error:1408F10B:SSL routines:ssl3_get_record:wrong version number (peer: 185.156.177.23)
2018.05.08 16:30:40 1: FHEMWEB SSL/HTTPS error: SSL accept attempt failed error:1408F10B:SSL routines:ssl3_get_record:wrong version number (peer: 185.156.177.29)
2018.05.08 16:30:40 1: FHEMWEB SSL/HTTPS error: SSL accept attempt failed error:1408F10B:SSL routines:ssl3_get_record:wrong version number (peer: 185.156.177.29)
Kann da ein Profi nötiges zum Bannen mit fail2ban beisteuern? Das wär schon fein, manchmal tauchen richtige viele Fehler auf, ich würde die gern verbannen >:(
Danke & Grüße,
Lutz
Ernsthaft ... verwende einen Http-Server (apache, nginx) als Proxy. Genau solche "Protokoll-Fehler" werden von diesen Serverdiensten am besten abgefangen.
Hallo Werniemann,
hab's mit nginx schwer gehabt, und nicht wirklich hinbekommen, da ich von einem Router (=meiner Dyn-Wan-IP) auf einen internen Host mit nginx und 2 Serverprog zugreifen will (d.h. 1x nginx-Server + 1 Server der eigentlich auf 80/443 sein will + 1x Fhem) .
Die Wiki-Anleitung hatte nicht ganz so funktioniert und mit den Zertifikaten und Authentication ist mir das nicht so ganz gelungen, so das ich mit Fhem grad wieder über Port xxx unterwegs bin - und das macht in WWW-LAN's mit restriktiver Outgoing-Firewall auch so seine Probleme.
Da muss ich wohl mal wieder nginx anwerfen. Das Problem ist mein anderer Server, der selber https bei Bedarf erzwingt und Zertifikat verwaltet - ich hatte nginx nicht wirklich zum nackten "Portforwarding" ohne alles zu diesem Server und andererseits zu erzwungenem HTTPS mit Authentication zu Fhem konfiguriert bekommen - vielleicht eben auch, weil beide auf dem gleichen internen Host sind :(
Aber es wär der richtige Weg... vielleicht müßte ich einen zusätzlichen Pi opfern um das hinzubekommen in dem ich mindestens nginx separiere...
Grüße, Lutz
Was hast Du denn als "anderen Webserver"?
Tja - ein ziemliches Special: Barracudadrive hieß es früher, heute Fuguhub bzw. Makoserver - ist klein schlank, einfache Administration, CMS, Webdav und dynamische Lua-Script-Seiten/Web-Apps, Banning eingebaut ... uvm - und lief auch früher schon flott & locker flockig auf RPi1...
So einfach wie er funktioniert ist aber auch best. Funktion nicht vollkommen: er kann auch reverseProxy, aber fängt dabei FHEM-interne JSON-Eventmeldung ab und bringt da Fehler...
d.h. als Proxy nicht zu gebrauchen .. und Du wirst deshalb bestimmt Deine Projekte nicht nach nginx portieren ...
Jepp... den will ich lieber für all das was er mit sein paar bin's, einer table, cache und zip's kann, behalten. Wordpress,Jomla o.ä. - für mich oversized und je größer = unüberschaubarer = angreifbarer ...
Eigentlich könnte man im Makoserver/Fuguhub direkt eine FHEM-Oberfläche proggen (Https, Websockets, AJAX, Lua-/Java-/C-Script/JSON/Threats... alles über API möglich) :)...
aber so ein Prog-Künstler bin ich dann doch nicht ::) :-[
... aber zurück zum Thema, falls das mit nginx nimmer wird:
Regex ist (weder bei fail2ban noch bei fhem) so mein Ding: könnte man in fail2ban nicht über eine überschaubare Regex auf alle "FHEMWEB SSL/HTTPS error:" filtern und die IP aus "(peer: xxx)" zum bannen rausziehen?
Jep .. siehe Doku zu fail2ban.
Sorry, aber das zu entwickeln/proggen hat für mich persönlich keinen Sinn ...
Zitatauf alle "FHEMWEB SSL/HTTPS error:" filtern und die IP aus "(peer: xxx)" zum bannen rausziehen?
dann pass mal auf, dass du dich nicht selber aussperrst. ;)
Leider funktioniert das ganze mit stretch und fail2ban Version 0.10.3 nicht mehr. :-\
Kann das mal einer wieder in Ordnung bringen!? ;)
Ohne weitere info als "Funktioniert nicht mehr" ... nein
Hatte etwas vergessen, läuft wieder! :)
nach einem update upgrade blockt fail2ban keine IP-Adressen mehr!
Habe sicherheitshalber mal ein altes Image genommen, wo noch alles funktioniert hat.
Nach einem update/upgrade des Raspberry Pi läuft wohl alles wie gehabt, nur nicht fail2ban! :-\
Danke für die Info. Gut zu wissen.
Grüße
Fehler gefunden!
Es war doch das FHEM-Update dass das verbockt hat!
Und zwar heißt es in der FHEM Logdatei nicht mehr "Login denied by allowed_WEB for ..."
sondern jetzt "Login denied for user ..."
Diese Änderung muss in:
/etc/fail2ban/filter.d/fhem.conf
angepasst werden!
Der neue Filter sollte dann so aussehen:
# Fail2ban filter for fhem
[INCLUDES]
before = common.conf
[Definition]
failregex = ^(.*?)Login denied (.*?)_<HOST>_
ignoreregex =
Man, was habe ich gesucht und kein Hinweis darauf dass sich die LOG in dieser Hinsicht geändert hat.
Schande über den der das geändert hat! ;D
Hi,
und ich hab mich heute gewundert warum Fhem nicht mehr dicht macht wenn ich mich beim Passwort vertippe ::)
Ich meine in einer Ankündigung / Diskussion davon gelesen zu haben. Ging um Änderungen wie allowed arbeitet.
Gesendet von meinem Doogee S60 mit Tapatalk
Hier:
https://forum.fhem.de/index.php/topic,92423
- protokollieren der fehlgeschlagenen Logins: es wird nicht mehr im allowed Instanz sondern uebergreifend protolliert. Bei zwei allowed Instanzen fuer das gleiche FHEMWEB sagt einer immer nein, und das wurde bisher protokolliert, ab jetzt nur dann, falls keiner OK sagt.
Gesendet von meinem Doogee S60 mit Tapatalk
Hallo zusammen,
funktioniert bei Euch das fail2ban Script noch?
Ich habe seit dem neuen allowed wieder diverse Anmeldeversuche von dubiosen IPs, die normalerweise immer nach 2 falsch -Versuchen blockiert wurden.
LG
Ein Optimierungsvorschlag:
Setze Dir loieber ein HTTP-Proxy (nginx oder apache) mit Authentifizierung davor. Dann klappt es auch wieder mit fail2ban und hat eine erhöhte Sicherheit ...
https://forum.fhem.de/index.php/topic,84576.msg851833.html#msg851833 (https://forum.fhem.de/index.php/topic,84576.msg851833.html#msg851833)
Zitat von: CBSnake am 22 November 2018, 13:10:27
https://forum.fhem.de/index.php/topic,84576.msg851833.html#msg851833 (https://forum.fhem.de/index.php/topic,84576.msg851833.html#msg851833)
VIELEN DANK !!!
Wie kriege ich es am besten hin dass fail2ban am ersten jeden Monats neu startet?
Machst du mMn am besten per Cronjob. Aber warum willst du das, wenn ich fragen darf?
Zitat von: vbs am 01 Januar 2019, 12:23:11
Machst du mMn am besten per Cronjob. Aber warum willst du das, wenn ich fragen darf?
Ja, du darfst fragen :)
Da das fhem-LOG jeden Monat neu erstellt wird, also von
fhem-2018-12.log nach
fhem-2019-01.log wechselt, sucht fail2ban weiterhin im alten LOG, also in
fhem-2018-12.log, wenn ich allerdings fail2ban neu starte, so nimmt er dann die aktuell LOG, also
fhem-2019-01.log.
Da ich mich aber mit Linux nicht so gut auskenne und Cronjob noch nie angewandt habe, habe ich hier mal lieber diese Frage eingestellt. :)
wäre das richtig:
1 * 1 1-12 *
???
oder reicht das:
1 * 1 * *
Nicht ganz:
http://cron.schlitt.info/index.php?cron=1+*+1+1-12+*&iterations=10&test=Test (http://cron.schlitt.info/index.php?cron=1+*+1+1-12+*&iterations=10&test=Test)
Probier mal sowas:
http://cron.schlitt.info/index.php?cron=30+0+1+*+*&iterations=10&test=Test (http://cron.schlitt.info/index.php?cron=30+0+1+*+*&iterations=10&test=Test)
Ich denke, man bekommt es auch mit dem client hin, ihn dazu zu bringen, das neue Log zu lesen. Da muss man evtl. nicht den ganzen Prozess neu starten:
https://www.fail2ban.org/wiki/index.php/Commands
1 0 1 1-12 *
scheint richtig zu sein! :)
So, habs eingetragen, muss jetzt nur bis Februar warten. :)
Mir scheint ich bin zu blöd. Nach Anleitung erster Post gemacht, kriege aber jail2ban nicht zum Laufen.
Ohne fhem jail läuft es. Füge ich ans Ende der jail.local den Text ein und starte neu, kriege ich einen Haufen FMs.
Jan 09 11:16:40 raspberrypi fail2ban[13833]: Starting authentication failure monitor: fail2banWARNING 'enabled' not defined in 'fhem'. Using default one: 'false'
Jan 09 11:16:40 raspberrypi fail2ban[13833]: WARNING 'logpath' not defined in 'fhem'. Using default one: '/var/log/messages'
Jan 09 11:16:40 raspberrypi fail2ban[13833]: WARNING 'filter' not defined in 'fhem'. Using default one: ''
Jan 09 11:16:40 raspberrypi fail2ban[13833]: ERROR Failed during configuration: Bad value substitution:
Jan 09 11:16:40 raspberrypi fail2ban[13833]: section: [fhem]
Jan 09 11:16:40 raspberrypi fail2ban[13833]: option : action
Jan 09 11:16:40 raspberrypi fail2ban[13833]: key : port
Jan 09 11:16:40 raspberrypi fail2ban[13833]: rawval : ", protocol="%(protocol)s", chain="%(chain)s"]
Jan 09 11:16:40 raspberrypi fail2ban[13833]: failed!
Jan 09 11:16:40 raspberrypi systemd[1]: Started LSB: Start/stop fail2ban.
Was hast Du denn in der Jail genau reingeschrieben?
Bitte um Input für Output
In der fhem.conf
# Fail2ban filter for fhem
[INCLUDES]
before = common.conf
[Definition]
failregex = ^(.*?)Login denied (.*?)_<HOST>_
ignoreregex =
jail.local
pi@raspberrypi:~ $ cat /etc/fail2ban/jail.local
# Fail2Ban configuration file.
#
# This file was composed for Debian systems from the original one
# provided now under /usr/share/doc/fail2ban/examples/jail.conf
# for additional examples.
#
# Comments: use '#' for comment lines and ';' for inline comments
#
# To avoid merges during upgrades DO NOT MODIFY THIS FILE
# and rather provide your changes in /etc/fail2ban/jail.local
#
# The DEFAULT allows a global definition of the options. They can be overridden
# in each jail afterwards.
[DEFAULT]
# "ignoreip" can be an IP address, a CIDR mask or a DNS host. Fail2ban will not
# ban a host which matches an address in this list. Several addresses can be
# defined using space separator.
ignoreip = 127.0.0.1/8
# External command that will take an tagged arguments to ignore, e.g. <ip>,
# and return true if the IP is to be ignored. False otherwise.
#
# ignorecommand = /path/to/command <ip>
ignorecommand =
# "bantime" is the number of seconds that a host is banned.
bantime = 600
# A host is banned if it has generated "maxretry" during the last "findtime"
# seconds.
findtime = 600
maxretry = 3
# "backend" specifies the backend used to get files modification.
# Available options are "pyinotify", "gamin", "polling" and "auto".
# This option can be overridden in each jail as well.
#
# pyinotify: requires pyinotify (a file alteration monitor) to be installed.
# If pyinotify is not installed, Fail2ban will use auto.
# gamin: requires Gamin (a file alteration monitor) to be installed.
# If Gamin is not installed, Fail2ban will use auto.
# polling: uses a polling algorithm which does not require external libraries.
# auto: will try to use the following backends, in order:
# pyinotify, gamin, polling.
backend = auto
# "usedns" specifies if jails should trust hostnames in logs,
# warn when reverse DNS lookups are performed, or ignore all hostnames in logs
#
# yes: if a hostname is encountered, a reverse DNS lookup will be performed.
# warn: if a hostname is encountered, a reverse DNS lookup will be performed,
# but it will be logged as a warning.
# no: if a hostname is encountered, will not be used for banning,
# but it will be logged as info.
usedns = warn
#
# Destination email address used solely for the interpolations in
# jail.{conf,local} configuration files.
destemail = root@localhost
#
# Name of the sender for mta actions
sendername = Fail2Ban
# Email address of the sender
sender = fail2ban@localhost
#
# ACTIONS
#
# Default banning action (e.g. iptables, iptables-new,
# iptables-multiport, shorewall, etc) It is used to define
# action_* variables. Can be overridden globally or per
# section within jail.local file
banaction = iptables-multiport
# email action. Since 0.8.1 upstream fail2ban uses sendmail
# MTA for the mailing. Change mta configuration parameter to mail
# if you want to revert to conventional 'mail'.
mta = sendmail
# Default protocol
protocol = tcp
# Specify chain where jumps would need to be added in iptables-* actions
chain = INPUT
#
# Action shortcuts. To be used to define action parameter
# The simplest action to take: ban only
action_ = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
# ban & send an e-mail with whois report to the destemail.
action_mw = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
%(mta)s-whois[name=%(__name__)s, dest="%(destemail)s", protocol="%(protocol)s", chain="%(chain)s", sendername="%(sendername)s"]
# ban & send an e-mail with whois report and relevant log lines
# to the destemail.
action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s", chain="%(chain)s"]
%(mta)s-whois-lines[name=%(__name__)s, dest="%(destemail)s", logpath=%(logpath)s, chain="%(chain)s", sendername="%(sendername)s"]
# Choose default action. To change, just override value of 'action' with the
# interpolation to the chosen action shortcut (e.g. action_mw, action_mwl, etc) in jail.local
# globally (section [DEFAULT]) or per specific section
action = %(action_)s
#
# JAILS
#
# Next jails corresponds to the standard configuration in Fail2ban 0.6 which
# was shipped in Debian. Enable any defined here jail by including
#
# [SECTION_NAME]
# enabled = true
#
# in /etc/fail2ban/jail.local.
#
# Optionally you may override any other parameter (e.g. banaction,
# action, port, logpath, etc) in that section within jail.local
[ssh]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/auth.log
maxretry = 6
[dropbear]
enabled = false
port = ssh
filter = dropbear
logpath = /var/log/auth.log
maxretry = 6
# Generic filter for pam. Has to be used with action which bans all ports
# such as iptables-allports, shorewall
[pam-generic]
enabled = false
# pam-generic filter can be customized to monitor specific subset of 'tty's
filter = pam-generic
# port actually must be irrelevant but lets leave it all for some possible uses
port = all
banaction = iptables-allports
port = anyport
logpath = /var/log/auth.log
maxretry = 6
[xinetd-fail]
enabled = false
filter = xinetd-fail
port = all
banaction = iptables-multiport-log
logpath = /var/log/daemon.log
maxretry = 2
[ssh-ddos]
enabled = false
port = ssh
filter = sshd-ddos
logpath = /var/log/auth.log
maxretry = 6
# Here we use blackhole routes for not requiring any additional kernel support
# to store large volumes of banned IPs
[ssh-route]
enabled = false
filter = sshd
action = route
logpath = /var/log/sshd.log
maxretry = 6
# Here we use a combination of Netfilter/Iptables and IPsets
# for storing large volumes of banned IPs
#
# IPset comes in two versions. See ipset -V for which one to use
# requires the ipset package and kernel support.
[ssh-iptables-ipset4]
enabled = false
port = ssh
filter = sshd
banaction = iptables-ipset-proto4
logpath = /var/log/sshd.log
maxretry = 6
[ssh-iptables-ipset6]
enabled = false
port = ssh
filter = sshd
banaction = iptables-ipset-proto6
logpath = /var/log/sshd.log
maxretry = 6
#
# HTTP servers
#
[apache]
enabled = false
port = http,https
filter = apache-auth
logpath = /var/log/apache*/*error.log
maxretry = 6
# default action is now multiport, so apache-multiport jail was left
# for compatibility with previous (<0.7.6-2) releases
[apache-multiport]
enabled = false
port = http,https
filter = apache-auth
logpath = /var/log/apache*/*error.log
maxretry = 6
[apache-noscript]
enabled = false
port = http,https
filter = apache-noscript
logpath = /var/log/apache*/*error.log
maxretry = 6
[apache-overflows]
enabled = false
port = http,https
filter = apache-overflows
logpath = /var/log/apache*/*error.log
maxretry = 2
[apache-modsecurity]
enabled = false
filter = apache-modsecurity
port = http,https
logpath = /var/log/apache*/*error.log
maxretry = 2
[apache-nohome]
enabled = false
filter = apache-nohome
port = http,https
logpath = /var/log/apache*/*error.log
maxretry = 2
# Ban attackers that try to use PHP's URL-fopen() functionality
# through GET/POST variables. - Experimental, with more than a year
# of usage in production environments.
[php-url-fopen]
enabled = false
port = http,https
filter = php-url-fopen
logpath = /var/www/*/logs/access_log
# A simple PHP-fastcgi jail which works with lighttpd.
# If you run a lighttpd server, then you probably will
# find these kinds of messages in your error_log:
# ALERT – tried to register forbidden variable 'GLOBALS'
# through GET variables (attacker '1.2.3.4', file '/var/www/default/htdocs/index.php')
[lighttpd-fastcgi]
enabled = false
port = http,https
filter = lighttpd-fastcgi
logpath = /var/log/lighttpd/error.log
# Same as above for mod_auth
# It catches wrong authentifications
[lighttpd-auth]
enabled = false
port = http,https
filter = suhosin
logpath = /var/log/lighttpd/error.log
[nginx-http-auth]
enabled = false
filter = nginx-http-auth
port = http,https
logpath = /var/log/nginx/error.log
# Monitor roundcube server
[roundcube-auth]
enabled = false
filter = roundcube-auth
port = http,https
logpath = /var/log/roundcube/userlogins
[sogo-auth]
enabled = false
filter = sogo-auth
port = http, https
# without proxy this would be:
# port = 20000
logpath = /var/log/sogo/sogo.log
#
# FTP servers
#
[vsftpd]
enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = vsftpd
logpath = /var/log/vsftpd.log
# or overwrite it in jails.local to be
# logpath = /var/log/auth.log
# if you want to rely on PAM failed login attempts
# vsftpd's failregex should match both of those formats
maxretry = 6
[proftpd]
enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = proftpd
logpath = /var/log/proftpd/proftpd.log
maxretry = 6
[pure-ftpd]
enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = pure-ftpd
logpath = /var/log/syslog
maxretry = 6
[wuftpd]
enabled = false
port = ftp,ftp-data,ftps,ftps-data
filter = wuftpd
logpath = /var/log/syslog
maxretry = 6
#
# Mail servers
#
[postfix]
enabled = false
port = smtp,ssmtp,submission
filter = postfix
logpath = /var/log/mail.log
[couriersmtp]
enabled = false
port = smtp,ssmtp,submission
filter = couriersmtp
logpath = /var/log/mail.log
#
# Mail servers authenticators: might be used for smtp,ftp,imap servers, so
# all relevant ports get banned
#
[courierauth]
enabled = false
port = smtp,ssmtp,submission,imap2,imap3,imaps,pop3,pop3s
filter = courierlogin
logpath = /var/log/mail.log
[sasl]
enabled = false
port = smtp,ssmtp,submission,imap2,imap3,imaps,pop3,pop3s
filter = postfix-sasl
# You might consider monitoring /var/log/mail.warn instead if you are
# running postfix since it would provide the same log lines at the
# "warn" level but overall at the smaller filesize.
logpath = /var/log/mail.log
[dovecot]
enabled = false
port = smtp,ssmtp,submission,imap2,imap3,imaps,pop3,pop3s
filter = dovecot
logpath = /var/log/mail.log
# To log wrong MySQL access attempts add to /etc/my.cnf:
# log-error=/var/log/mysqld.log
# log-warning = 2
[mysqld-auth]
enabled = false
filter = mysqld-auth
port = 3306
logpath = /var/log/mysqld.log
# DNS Servers
# These jails block attacks against named (bind9). By default, logging is off
# with bind9 installation. You will need something like this:
#
# logging {
# channel security_file {
# file "/var/log/named/security.log" versions 3 size 30m;
# severity dynamic;
# print-time yes;
# };
# category security {
# security_file;
# };
# };
#
# in your named.conf to provide proper logging
# !!! WARNING !!!
# Since UDP is connection-less protocol, spoofing of IP and imitation
# of illegal actions is way too simple. Thus enabling of this filter
# might provide an easy way for implementing a DoS against a chosen
# victim. See
# http://nion.modprobe.de/blog/archives/690-fail2ban-+-dns-fail.html
# Please DO NOT USE this jail unless you know what you are doing.
#[named-refused-udp]
#
#enabled = false
#port = domain,953
#protocol = udp
#filter = named-refused
#logpath = /var/log/named/security.log
[named-refused-tcp]
enabled = false
port = domain,953
protocol = tcp
filter = named-refused
logpath = /var/log/named/security.log
[freeswitch]
enabled = false
filter = freeswitch
logpath = /var/log/freeswitch.log
maxretry = 10
action = iptables-multiport[name=freeswitch-tcp, port="5060,5061,5080,5081", protocol=tcp]
iptables-multiport[name=freeswitch-udp, port="5060,5061,5080,5081", protocol=udp]
[ejabberd-auth]
enabled = false
filter = ejabberd-auth
port = xmpp-client
protocol = tcp
logpath = /var/log/ejabberd/ejabberd.log
# Multiple jails, 1 per protocol, are necessary ATM:
# see https://github.com/fail2ban/fail2ban/issues/37
[asterisk-tcp]
enabled = false
filter = asterisk
port = 5060,5061
protocol = tcp
logpath = /var/log/asterisk/messages
[asterisk-udp]
enabled = false
filter = asterisk
port = 5060,5061
protocol = udp
logpath = /var/log/asterisk/messages
# Jail for more extended banning of persistent abusers
# !!! WARNING !!!
# Make sure that your loglevel specified in fail2ban.conf/.local
# is not at DEBUG level -- which might then cause fail2ban to fall into
# an infinite loop constantly feeding itself with non-informative lines
[recidive]
enabled = false
filter = recidive
logpath = /var/log/fail2ban.log
action = iptables-allports[name=recidive]
sendmail-whois-lines[name=recidive, logpath=/var/log/fail2ban.log]
bantime = 604800 ; 1 week
findtime = 86400 ; 1 day
maxretry = 5
# See the IMPORTANT note in action.d/blocklist_de.conf for when to
# use this action
#
# Report block via blocklist.de fail2ban reporting service API
# See action.d/blocklist_de.conf for more information
[ssh-blocklist]
enabled = false
filter = sshd
action = iptables[name=SSH, port=ssh, protocol=tcp]
sendmail-whois[name=SSH, dest="%(destemail)s", sender="%(sender)s", sendername="%(sendername)s"]
blocklist_de[email="%(sender)s", apikey="xxxxxx", service="%(filter)s"]
logpath = /var/log/sshd.log
maxretry = 20
# consider low maxretry and a long bantime
# nobody except your own Nagios server should ever probe nrpe
[nagios]
enabled = false
filter = nagios
action = iptables[name=Nagios, port=5666, protocol=tcp]
sendmail-whois[name=Nagios, dest="%(destemail)s", sender="%(sender)s", sendername="%(sendername)s"]
logpath = /var/log/messages ; nrpe.cfg may define a different log_facility
maxretry = 1
[fhem]
enabled = true
port = 8083
action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp]
%(mta)s-whois[name=%(__name__)s, dest="%(destemail)s"]
filter = fhem
logpath = /opt/fhem/log/fhem-20*
maxretry = 10
bantime = 86400
sind die Berechtigungen bzw Gruppe und Eigentümer der "jail.local" die gleichen wie bei "jail.conf"!?
Die "fhem.conf" auch kontrollieren!
2x ja
Hab auch schon nach Steuerzeichen gesucht, die beim Kopieren mitgekommen sind. :(
irgendwie scheint mir das eine alte Version von "fail2ban" zu sein, in der neuesten Version wird "enabled = true" für
die einzelnen jails in der Datei "jail.d/defaults-debian.conf" gesetzt. ???
bei mir gibt es in der "jail.local" kein "enabled = true" mehr!
@Tom
Beide Wege sind Möglich, keine Aufregung!
Nur .. müste es nicht eigentlich jail.conf und nicht jail.local lauten??
Mir ist nur für die Fehlersuche die Config zu unübersichtlich.
Kannst Du bitte mal alle Jails, welche nicht enabled sind, aus der Config rauswerfen (vorher copy machen)?
P.S: Bitte auch mal die fail2ban.conf und die defaults-debian.conf
Zitat von: Wernieman am 09 Januar 2019, 15:31:59
@Tom
Beide Wege sind Möglich, keine Aufregung!
ja sicher sind auch beide Wege möglich, nur frage ich mich wenn Maui fail2ban erst letztens installiert hat wieso das dann noch vorkommt!?
seit Februar 2018 gibt es bereits die ausgekoppelte Version von fail2ban!
Zitat von: Wernieman am 09 Januar 2019, 15:31:59
Nur .. müste es nicht eigentlich jail.conf und nicht jail.local lauten??
Da die jail.conf nach jedem Update erneuert wird wäre es unsinnig dort das jail von fhem reizupacken, deshalb sollte man ein jail.local anlegen!
Danke euch beiden für eure Hilfe. Hab zu Hause mal die jail.local gelöscht und nur den Fhem jail in die neue jail.local geschrieben. Zusätzlich hab ich per iPhone (statt windoof Rechner) kopiert. Jetzt geht es. Denke eher es lag an Teil 2 also verrückten Steuerzeichen vorher.
Zu Teil 1. es reicht wohl das Delta zur jail.conf in die jail.local zu schreiben. Fühlt sich auch richtiger an.
@Tom:
Die jail.conf wird NICHT ungefragt überschrieben bei einem update!
Wie ich schrieb: Keine Aufregung ...
@Maui
Ich denke, es lag am Windows-Editor.
Mal auf die schnelle:
https://www.qfs.de/qf-test-handbuch/lc/manual-de-tech_linebreaks.html (https://www.qfs.de/qf-test-handbuch/lc/manual-de-tech_linebreaks.html)
Jetzt wo es geht, hab ich mich mal dran gemacht, die "olle" Mail Action gegen eine telegram Nachricht zu tauschen.
Falls es jmd interessiert, hier mal grob die nötigen Schritte.
Neue Action anlegen:
sudo nano /etc/fail2ban/action.d/fhem_ac.conf
# Fail2Ban configuration file
#
# Author: Cyril Jaquier
#
#
[Definition]
# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
# Values: CMD
#
#actionstart = touch /var/run/fail2ban/fail2ban.dummy
# printf %%b "<init>\n" >> /var/run/fail2ban/fail2ban.dummy
# Option: actionstop
# Notes.: command executed once at the end of Fail2Ban
# Values: CMD
#
#actionstop = rm -f /var/run/fail2ban/fail2ban.dummy
# Option: actioncheck
# Notes.: command executed once before each actionban command
# Values: CMD
#
#actioncheck =
# 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 = printf %%b "+<ip>\n" >> /var/run/fail2ban/fail2ban.dummy
#actionban = /home/pi/fhem_tele.sh <ip>
actionban = echo "set telebot message IP geblockt: <ip>" | /bin/nc -w5 127.0.0.1 7072
# 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 = printf %%b "-<ip>\n" >> /var/run/fail2ban/fail2ban.dummy
[Init]
# init = 123
Die Action muss unter actionban dann natürlich noch auf die eigenen Zwecke angepasst werden.
In der jail.local reicht es dann die Mail-Zeile gegen fhem_ac zu tauschen.
Meine vollständige Datei dazu auch noch mal.
[fhem]
enabled = true
port = 8083
action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp]
fhem_ac
filter = fhem
logpath = /opt/fhem/log/fhem-20*
maxretry = 3
bantime = 86400
Nun muss nur noch fail2ban neu gestartet werden.
sudo /etc/init.d/fail2ban restart
Geht so allerdings nur, wenn:
1. Telnet-Zugang in FHEM eingrichtet
2. Kein Passwort
3. Kein SSL-Aktiv
4. FHEM auf dem gleichen Rechner
Wobei alles 4 auch "behoben" werden kann ;o)
Wird aber alles 4 bei einem OOTB fhem so sein.
Warum denn bitte SSL? SSL over Telnet?
Siehe Doku: http://www.fhem.de/commandref.html#telnet (http://www.fhem.de/commandref.html#telnet)
also eher telnet over ssl ;o)
Telnet ist mittlerweile Standardmäßig nicht mehr offen (Irgendwann Mitte 2018?)
Warum telnet und nicht ssh (o.Ä.) kann ich Dir nicht beantworten .....
Ich weiß ja was du sagen willst. Stimmt davon hab ich auch schonmal gelesen.
Ich wollte ja auch nur einen gangbaren lokalen Weg aufzeigen.
Dass der übers Internet völlig ungeeignet ist weiß ich.
Es soll ja auch nur ein Schnipsel und ein Ansatz sein. Wenn einer dann lieber ssh präferiert oder per curl, nur zu :P
Hey, ich gehe diesen Weg doch auch (nicht bei telegam, aber so Ähnlich), Also Intern gar nicht mal sooo schlecht und in Verglichen mit anderen Hausautomatisationssystemen auch nicht unsicherer (wenn man sich einige Gedanken macht)
Zitat von: Tom111 am 01 Januar 2019, 13:24:14
1 0 1 1-12 *
scheint richtig zu sein! :)
So, habs eingetragen, muss jetzt nur bis Februar warten. :)
Falls es jemanden interessiert,... es klappt! :)
Gab es wieder eine Änderung durch ein FHEM Update?
Inzwischen tauchen bei mir wieder vermehrt die Logon denied Einträge im LOG auf. Diese werden aber offensichtlich nicht beim 3. Mal gebant...
Danke für die Hilfe.
Zitat von: pillepalle12 am 17 Januar 2020, 06:33:05
Gab es wieder eine Änderung durch ein FHEM Update?
Inzwischen tauchen bei mir wieder vermehrt die Logon denied Einträge im LOG auf. Diese werden aber offensichtlich nicht beim 3. Mal gebant...
Danke für die Hilfe.
Also bei mir funktioniert noch alles!
Die Fragen sind:
- in welchem Zeitraum kommen die Denys
- welchen Suchzeitraum in Fail2Ban hast Du eingestellt
mach doch mal auf der Kommandooberfläche:
fail2ban-client status
Kurze Frage dazu:
ich will das für meinen ReverseProxy aufsetzten.
Habe alles so weit eingerichtet, komme aber jetzt mit der RegEx nicht weiter :-[ wir zwei stehen auf Kriegsfuß ;D
So sieht eine Logzeile aus:
[Sat Feb 08 08:54:08.984255 2020] [auth_basic:error] [pid 5090] [client 92.246.76.202:59053] AH01618: user admin not found: /fhem, referer: https://87.147.196.221/
Jetzt muss ich da ja die IP rausziehen (sollte die hinter Client sein) und am besten auf AH01618 oder [auth_basic:error] "filtern".
Leider bekomme ich es ums verrecken nicht hin...bin zu blöd... :-[
Ungetestet:
^.*auth_basic:error.*client <HOST>] AH01618: user admin not found.*$
Mir sieht das Logfileformat am Anfang, also der Zeitstempel, komisch aus. Was ist es denn für ein Logfile??
Apache2, der error log
Gucke Dir doch mal die fertigen Filter für apache2 an:
/etc/fail2ban/filter.d/apache-auth.conf
Allerdings würde ich vorschlagen, dafür einen neuen Thread zu eröffnen .... geht jetzt doch an der Ursprünglichen Fragestellung vorbei ...
Ne, hilft leider nicht.
Hab es jetzt aber hinbekommen: ^.*(client )<HOST>.*(AH01618)
Vielen Dank!
Wollte nochmal melden, geht jetzt perfekt inkl. Pushover Benachrichtigung.
Hallo Zusammen,
ich musste mein FHEM komplett neu aufsetzen, da mein Jesse zu alt wurde und keine Updates mehr bekommen hat.
Nun wollte ich auch fail2ban wieder installieren, hat vom Install auch alles geklappt, es wird aber nicht geblockt, ich kann 30 mal das falsche PW versuchen und werde nicht gebannt...
Ist fail2ban noch aktuell und sollte funktionieren oder wurde es abgeschafft? nutzt es noch jemand?
Danke Euch
Meine persönliche Meinung?
Am besten FHEM nicht erreichbar machen (bzw., nur mit VPN). Und wenn doch nötig,(wie bei mir) einem passwortgeschützten Reserve-Proxy ... und den mit fail2ban absichern ....
Zitat von: Wernieman am 23 Januar 2022, 17:43:06
Meine persönliche Meinung?
Am besten FHEM nicht erreichbar machen (bzw., nur mit VPN). Und wenn doch nötig,(wie bei mir) einem passwortgeschützten Reserve-Proxy ... und den mit fail2ban absichern ....
Ergänzung:
Ich habe es genau so und zusätzlich das Modul für Google Authenticator.
Kommandos werden mit einem OTP ergänzt, welches erst geprüft wird und wenn gültig, wird der mitgeschickte Befehl ausgeführt.
Zitat von: pillepalle12 am 23 Januar 2022, 14:51:18
Ist fail2ban noch aktuell und sollte funktionieren oder wurde es abgeschafft? nutzt es noch jemand?
Danke Euch
Ja, ich nutze es noch und es funktioniert einwandfrei!
Zitat von: Wernieman am 23 Januar 2022, 17:43:06
Meine persönliche Meinung?
Am besten FHEM nicht erreichbar machen (bzw., nur mit VPN). Und wenn doch nötig,(wie bei mir) einem passwortgeschützten Reserve-Proxy ... und den mit fail2ban absichern ....
Die Antwort geht komplett an die Frage vorbei und hilft ihm keineswegs!
Das FHEM-Jail dient zur Absicherung in der letzten Instanz. Wenn ein User noch keinen passwortgesicherten Reverse_Proxy oder VPN hat, bringt es einen gewissen Grundschutz. Im Übrigen sollte Fail2Ban ebenfalls zwingend für den Reverse_Proxy und das VPN eingerichtet sein.
@pillepalle12
Fail2Ban blockt in der Standardkonfiguration keine lokalen Netzwerkadressen. Hast du es intern oder extern getestet?
Die Informationen für Fail2Ban kommen aus dem FHEM-Log. Ist der Pfad richtig eingetragen?
Der erfolglose Loginversuch wird auch nur dann ins Log geschrieben, wenn im Device "global" das Attribut "verbose" mit 3 oder höher eingetragen ist.
Gruß Jens
Danke Tom111 und Jens,
ich hab es extra extern übers Handy mit mobilen Daten getestet, auch der Pfad stimmt und global hat verbose 3... es ist mir ein Rätsel.
Werde jetzt nochmal fail2ban löschen und die Installation wiederholen, mal sehen ob ich es hin bekomme.
Danke Euch
Zitat von: pillepalle12 am 23 Januar 2022, 18:58:31
Danke Tom111 und Jens,
ich hab es extra extern übers Handy mit mobilen Daten getestet, auch der Pfad stimmt und global hat verbose 3... es ist mir ein Rätsel.
Werde jetzt nochmal fail2ban löschen und die Installation wiederholen, mal sehen ob ich es hin bekomme.
Danke Euch
Du hast aber schon die für fhem notwendigen Filter-Einstellungen eingegeben!?
Weil nur fail2ban installieren reicht ja nicht.
Gruß, Joachim
Und auch geprüft, ob die Loginversuche wirklich im FHEM-Logfile auftauchen?
Hinweis: Wir sind nicht unter WIndows, wo deinstallieren/installieren häufig Hilft.
@Tom111
ZitatDie Antwort geht komplett an die Frage vorbei und hilft ihm keineswegs!
... aber dieser Satz hilft ihm total ...
Danke für die weiteren Hinweise,
ja die Configs habe ich natürlich angepasst, inkl. Ports und die local angepasst, wie in der Anleitung.
Es hat in Jessy auch geklappt und seit Jahren funktioniert, nun leider nicht mehr.
Habe nochmal alle angepassten Dateien und Pfade geprüft, stimmt (leider) alles...
die "Login denied" Meldungen tauchen auch im FHEM Log auf, fail2ban sollte diese Meldungen auch finden, der /opt/fhem/log Pfad stimmt auch...
Bin ratlos...
Anbei noch meine Inhalte, evtl. bin ich inzwischen ja Betriebsblind :)
fhem.conf
# Fail2ban filter for fhem
[INCLUDES]
before = common.conf
[Definition]
failregex = ^(.*?)Login denied (.*?)_<HOST>_
ignoreregex =
jail.local
# JAILS
#
#
[fhem]
enabled = true
port = 8080
action = %(banaction)s[name=%(__name__)s-tcp, port="%(port)s", protocol="tcp", chain="%(chain)s", actname=%(banaction)s-tcp]
%(mta)s-whois[name=%(__name__)s, dest="%(destemail)s"]
filter = fhem
logpath = /opt/fhem/log/fhem-20*
maxretry = 2
bantime = 86400
Port 8080 stimmt?
Ja, der stimmt :)
Kommt was in /var/log/fail2ban.log an?
Guter Hinweis, hier hab ich noch gar nicht rein geschaut, ja das log ist voller Einträge, auch Fehlern:
der Hinweis "already banned" kann aber nicht stimmen, da ich mich immer noch einloggen kann vom Handy
The jail fhem has been started successfully.\n
Regards,\n
Fail2Ban" | /usr/sbin/sendmail -f "fail2ban" "root@localhost"
2022-01-23 19:42:35,740 fail2ban.utils [481]: ERROR 74381020 -- stderr: '/bin/sh: 8: /usr/sbin/sendmail: not found'
2022-01-23 19:42:35,741 fail2ban.jail [481]: INFO Jail 'sshd' started
2022-01-23 19:42:35,742 fail2ban.utils [481]: ERROR 74381020 -- returned 127
2022-01-23 19:42:35,745 fail2ban.utils [481]: INFO HINT on 127: "Command not found". Make sure that all commands in 'printf %b "Subject: [Fail2>
2022-01-23 19:42:35,746 fail2ban.actions [481]: ERROR Failed to start jail 'fhem' action 'sendmail-whois': Error starting action Jail('fhem')/sendm>
2022-01-23 19:42:35,748 fail2ban.actions [481]: NOTICE [fhem] Restore Ban 109.43.49.223
2022-01-23 19:42:35,765 fail2ban.utils [481]: ERROR 75a37d40 -- exec: iptables -w -N f2b-fhem-tcp
iptables -w -A f2b-fhem-tcp -j RETURN
iptables -w -I INPUT -p tcp -m multiport --dports 8080 -j f2b-fhem-tcp
2022-01-23 19:42:35,765 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 1: iptables: not found'
2022-01-23 19:42:35,766 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 2: iptables: not found'
2022-01-23 19:42:35,766 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 3: iptables: not found'
2022-01-23 19:42:35,767 fail2ban.utils [481]: ERROR 75a37d40 -- returned 127
2022-01-23 19:42:35,767 fail2ban.utils [481]: INFO HINT on 127: "Command not found". Make sure that all commands in 'iptables -w -N f2b-fhem-tc>
2022-01-23 19:42:35,767 fail2ban.actions [481]: ERROR Failed to execute ban jail 'fhem' action 'iptables-multiport-tcp' info 'ActionInfo({'ip': '10>
2022-01-23 19:42:35,769 fail2ban.actions [481]: NOTICE [fhem] Restore Ban 109.43.50.103
2022-01-23 19:42:35,781 fail2ban.utils [481]: ERROR 75a37d40 -- exec: iptables -w -N f2b-fhem-tcp
iptables -w -A f2b-fhem-tcp -j RETURN
iptables -w -I INPUT -p tcp -m multiport --dports 8080 -j f2b-fhem-tcp
2022-01-23 19:42:35,782 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 1: iptables: not found'
2022-01-23 19:42:35,783 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 2: iptables: not found'
2022-01-23 19:42:35,783 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 3: iptables: not found'
2022-01-23 19:42:35,783 fail2ban.utils [481]: ERROR 75a37d40 -- returned 127
2022-01-23 19:42:35,784 fail2ban.utils [481]: INFO HINT on 127: "Command not found". Make sure that all commands in 'iptables -w -N f2b-fhem-tc>
2022-01-23 19:42:35,784 fail2ban.actions [481]: ERROR Failed to execute ban jail 'fhem' action 'iptables-multiport-tcp' info 'ActionInfo({'ip': '10>
2022-01-23 19:42:35,785 fail2ban.actions [481]: NOTICE [fhem] Restore Ban 185.204.1.183
2022-01-23 19:42:35,798 fail2ban.utils [481]: ERROR 75a37d40 -- exec: iptables -w -N f2b-fhem-tcp
iptables -w -A f2b-fhem-tcp -j RETURN
iptables -w -I INPUT -p tcp -m multiport --dports 8080 -j f2b-fhem-tcp
2022-01-23 19:42:35,799 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 1: iptables: not found'
2022-01-23 19:42:35,799 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 2: iptables: not found'
2022-01-23 19:42:35,799 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 3: iptables: not found'
2022-01-23 19:42:35,800 fail2ban.utils [481]: ERROR 75a37d40 -- returned 127
2022-01-23 19:42:35,800 fail2ban.utils [481]: INFO HINT on 127: "Command not found". Make sure that all commands in 'iptables -w -N f2b-fhem-tc>
2022-01-23 19:42:35,801 fail2ban.actions [481]: ERROR Failed to execute ban jail 'fhem' action 'iptables-multiport-tcp' info 'ActionInfo({'ip': '18>
2022-01-23 19:42:35,802 fail2ban.actions [481]: NOTICE [fhem] Restore Ban 84.144.78.217
2022-01-23 19:42:35,814 fail2ban.utils [481]: ERROR 75a37d40 -- exec: iptables -w -N f2b-fhem-tcp
iptables -w -A f2b-fhem-tcp -j RETURN
iptables -w -I INPUT -p tcp -m multiport --dports 8080 -j f2b-fhem-tcp
2022-01-23 19:42:35,815 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 1: iptables: not found'
2022-01-23 19:42:35,815 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 2: iptables: not found'
2022-01-23 19:42:35,816 fail2ban.utils [481]: ERROR 75a37d40 -- stderr: '/bin/sh: 3: iptables: not found'
2022-01-23 19:42:35,816 fail2ban.utils [481]: ERROR 75a37d40 -- returned 127
2022-01-23 19:42:35,817 fail2ban.utils [481]: INFO HINT on 127: "Command not found". Make sure that all commands in 'iptables -w -N f2b-fhem-tc>
2022-01-23 19:42:35,817 fail2ban.actions [481]: ERROR Failed to execute ban jail 'fhem' action 'iptables-multiport-tcp' info 'ActionInfo({'ip': '84>
2022-01-23 20:00:57,565 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:00:57
2022-01-23 20:00:59,170 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:00:58
2022-01-23 20:00:59,213 fail2ban.actions [481]: WARNING [fhem] 109.43.50.103 already banned
2022-01-23 20:01:00,128 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:01:00
2022-01-23 20:01:01,735 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:01:01
2022-01-23 20:01:01,817 fail2ban.actions [481]: WARNING [fhem] 109.43.50.103 already banned
2022-01-23 20:01:02,535 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:01:02
2022-01-23 20:01:03,615 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:01:03
2022-01-23 20:01:04,021 fail2ban.actions [481]: WARNING [fhem] 109.43.50.103 already banned
2022-01-23 20:01:04,907 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:01:04
2022-01-23 20:01:06,954 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:01:06
2022-01-23 20:01:07,226 fail2ban.actions [481]: WARNING [fhem] 109.43.50.103 already banned
2022-01-23 20:01:08,561 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:01:08
2022-01-23 20:24:08,135 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:24:08
2022-01-23 20:24:09,741 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:24:09
2022-01-23 20:24:10,290 fail2ban.actions [481]: WARNING [fhem] 109.43.50.103 already banned
2022-01-23 20:24:10,723 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:24:10
2022-01-23 20:24:12,329 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:24:12
2022-01-23 20:24:12,494 fail2ban.actions [481]: WARNING [fhem] 109.43.50.103 already banned
2022-01-23 20:24:13,393 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:24:13
2022-01-23 20:24:14,551 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:24:14
2022-01-23 20:24:14,698 fail2ban.actions [481]: WARNING [fhem] 109.43.50.103 already banned
2022-01-23 20:24:15,700 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 20:24:15
2022-01-23 21:05:27,322 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 21:05:27
2022-01-23 21:05:29,357 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 21:05:29
2022-01-23 21:05:30,015 fail2ban.actions [481]: WARNING [fhem] 109.43.50.103 already banned
2022-01-23 21:05:31,134 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 21:05:31
2022-01-23 21:05:33,841 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 21:05:33
2022-01-23 21:05:34,021 fail2ban.actions [481]: WARNING [fhem] 109.43.50.103 already banned
2022-01-23 21:05:35,674 fail2ban.filter [481]: INFO [fhem] Found 109.43.50.103 - 2022-01-23 21:05:35
FEHLER GEFUNDEN!! :)
Dank Deinem Log Hinweis hab ich herausgefunden, dass das IP Tables Paket nicht installiert war: sudo apt install iptables
Jetzt funktioniert es.
VIELEN VIELEN DANK EUCH ALLEN!!
Danke, das Du eine Erfolgmeldung gebracht hat.
Das Sahnehäubchen wäre. wenn Du im ersten Post den Titel ergänzt mit [gelöst] o.Ä.