Configuration fail2ban domoticz

Forum dédié à l'accès à DomoticZ depuis l'extérieur de chez vous : routage de ports, VPN, VPS ...
La sécurité, c'est important !!
klarf
Messages : 136
Inscription : 17 mars 2018, 09:00

Configuration fail2ban domoticz

Message par klarf »

Bonjour,

j'ai installé fail2ban sur mon raspberry pi 3b+ mais je n'arrive pas à le faire marcher.

Sur le log domoticz j'ai ceci :

Code : Tout sélectionner

2025-03-21 02:11:56.706 Error: Error parsing http request address: ::ffff:172.105.246.139
2025-03-21 02:11:56.765 Error: Error parsing http request address: ::ffff:172.105.246.139
2025-03-21 02:11:56.823 Error: Error parsing http request address: ::ffff:172.105.246.139
2025-03-21 03:32:16.563 Error: Error parsing http request address: ::ffff:101.198.0.150
2025-03-21 03:32:17.628 Error: Error parsing http request address: ::ffff:101.198.0.180
J'ai ceci en configuration :
/etc/fail2ban/jail.conf

Code : Tout sélectionner

[domoticz]
enabled  = true
port     = 8084
filter   = domoticz
logpath  = /tmp/domoticz.txt
maxretry = 3
findtime = 3600

[domoticzssl]
enabled  = true
port     = 8443
filter   = domoticz
logpath  = /tmp/domoticz.txt
maxretry = 3
findtime = 3600
J'ai testé une seul configuration pour les 2 ports (port = 8084,8443) mais le résultat est identique.

etc/fail2ban/filter.d/domoticz.conf

Code : Tout sélectionner

  # Fail2Ban configuration file for domoticz
  #
  # Author: Domoticz user 'ThinkPad'
  #
  # $Revision$
  #
  
  [Definition]
  
  # Option:  failregex
  # Notes.:  regex to match the password failures messages in the logfile. The
  #          host must be matched by a group named "host". The tag "<HOST>" can
  #          be used for standard IP/hostname matching and is only an alias for
  #          (?:::f{4,6}:)?(?P<host>[\w\-.^_]+)
  # Values:  TEXT
  #
  failregex = Error: Error parsing http request address: <HOST>
                    Error: Failed login attempt from <HOST> for user '.*' !	
                    Error: Failed login attempt from <HOST> for '.*' !
                    Error: \[web:8080\] Failed authentication attempt, ignoring client request \(remote address: <HOST>\)
                    Error: \[web:8443\] Failed authentication attempt, ignoring client request \(remote address: <HOST>\)
  
  #First line is for 'Login Page' authentication mode of Domoticz
  #Second line is for 'Basic-Auth' authentication mode in Domoticz
  #
  #
  #
  # Option:  ignoreregex
  # Notes.:  regex to ignore. If this regex matches, the line is ignored.
  # Values:  TEXT
  #
  ignoreregex =
J'ai essayé avec des définitions "failregex" qui commence par ".*" mais c'est pareil. J'avais mis aussi "Error parsing http request address: ::ffff: <HOST>" mais même résultat.

Je ne sais pas où cela ne marche pas.
Quand je test la jail j'ai ceci :

fail2ban-regex /tmp/domoticz.txt /etc/fail2ban/filter.d/domoticz.conf /etc/fail2ban/filter.d/domoticz.conf

Code : Tout sélectionner

Running tests
=============

Use   failregex filter file : domoticz, basedir: /etc/fail2ban
Use ignoreregex line : /etc/fail2ban/filter.d/domoticz.conf
Use         log file : /tmp/domoticz.txt
Use         encoding : UTF-8


Results
=======

Failregex: 32 total
|-  #) [# of hits] regular expression
|   1) [32] .*Error: Error parsing http request address: <HOST>
`-

Ignoreregex: 0 total

Date template hits:
|- [# of hits] date format
|  [1170] {^LN-BEG}ExYear(?P<_sep>[-/.])Month(?P=_sep)Day(?:T|  ?)24hour:Minute:Second(?:[.,]Microseconds)?(?:\s*Zone offset)?
`-

Lines: 1215 lines, 0 ignored, 32 matched, 1183 missed
[processed in 1.59 sec]

Missed line(s): too many to print.  Use --print-all-missed to print all 1183 lines
Il reconnait quelques choses mais ne trouve pas les IP ? Dans tous les cas je n'ai aucune IP banni alors que fail2ban tourne depuis longtemps.

Merci d'avance pour votre aide !
denis_brasseur
Messages : 898
Inscription : 24 déc. 2018, 17:05
Localisation : (26)

Re: Configuration fail2ban domoticz

Message par denis_brasseur »

La syntaxe est bien celle ci :

Code : Tout sélectionner

 Error: Error parsing http request address: ::ffff:<HOST>
Pi3 + DD PiDrive - RFXtrx433 - AEON Labs ZW090
klarf
Messages : 136
Inscription : 17 mars 2018, 09:00

Re: Configuration fail2ban domoticz

Message par klarf »

Merci pour ta réponse.
J'ai bien mis cette expression mais cela ne semble pas marcher, je suis obliger de faire le ban manuellement via ligne de commande.

J'ai ceci :

Code : Tout sélectionner

sudo fail2ban-client status domoticzssl
Status for the jail: domoticzssl
|- Filter
|  |- Currently failed:	0
|  |- Total failed:	0
|  `- Journal matches:	
`- Actions
   |- Currently banned:	2
   |- Total banned:	2
   `- Banned IP list:	172.234.162.56 45.33.120.129
Est ce normal ou pas (les ip ont été mis manuellement sinon j'ai toujours 0)? Ai je raté quelque chose ?
jackslayter
Messages : 1040
Inscription : 30 sept. 2014, 14:40
Localisation : Isère (38)

Re: Configuration fail2ban domoticz

Message par jackslayter »

essai ça comme filtre :

Code : Tout sélectionner

failregex = ^<HOST> \- \S+ \[\] \"(GET|POST|HEAD) .+\" 401 .+$
Raspberry Pi + RFLink + Domoticz Beta
Oregon - 3x Thgr122Nx / Chacon - micromodule 200w, télécommande 3b et 16b, 2x module 1000w, détecteur de fumée, contact de porte, 2x prise 3500w / OWL - CM180 / TRC02 v2 RGB 3M / Cheap - PIR, contact de porte
klarf
Messages : 136
Inscription : 17 mars 2018, 09:00

Re: Configuration fail2ban domoticz

Message par klarf »

Merci, j'ai essayé il y a quelques jours et les résultats sont toujours pareil.
Il y a t'il une autre solution que fail2ban pour bloquer les connexions non désirées ?
Répondre