Currently, when someone tries to connect and fails, here is what we get in the logfile :
Code: Select all
2015-10-30 17:32:16.616 Error: Failed login attempt for 'toto' !
Thanks
Regards
Manu
Moderator: leecollings
Code: Select all
2015-10-30 17:32:16.616 Error: Failed login attempt for 'toto' !
Code: Select all
[domoticz]
enabled = true
port = 8080
filter = domoticz
logpath = /var/log/domoticz.log
maxretry = 3
findtime = 3600
Code: Select all
vi /etc/fail2ban/filter.d/domoticz.conf
# Fail2Ban configuration file for domoticz
#
# Author: Emmanuel Chanteloup
#
# $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: Failed login attempt from <HOST> for user '.*' !
# Option: ignoreregex
# Notes.: regex to ignore. If this regex matches, the line is ignored.
# Values: TEXT
#
ignoreregex =
Code: Select all
sudo /etc/init.d/fail2ban restart
Code: Select all
vi toto.txt :
2015-11-03 18:35:51.908 Error: Failed login attempt from 37.130.158.115 for user 'toto' !
Code: Select all
fail2ban-regex toto.txt /etc/fail2ban/filter.d/domoticz.conf
Code: Select all
Success, the total number of match is 1
Code: Select all
root@raspberrypi:/etc/fail2ban# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-domoticz tcp -- anywhere anywhere multiport dports 8080
fail2ban-ssh tcp -- anywhere anywhere multiport dports ssh
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain fail2ban-domoticz (1 references)
target prot opt source destination
DROP all -- 37.140.158.148 anywhere
RETURN all -- anywhere anywhere
Code: Select all
root@raspberrypi:/etc/fail2ban/filter.d# iptables -D fail2ban-domoticz -s YOUR_IP_HERE(37.140.158.148 for me) -j DROP
Code: Select all
root@raspberrypi:/etc/fail2ban# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
fail2ban-domoticz tcp -- anywhere anywhere multiport dports 8080
fail2ban-ssh tcp -- anywhere anywhere multiport dports ssh
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain fail2ban-domoticz (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Chain fail2ban-ssh (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
Thank you very much, was looking for this, to configure on my Ubuntu VM running Domoticz. Will try it soon!manuloup wrote:Here we go :
[...]
Code: Select all
domoticz@domoticz-vm:/etc/fail2ban/filter.d$ cat /var/log/domoticz.log | grep 'Failed'
2015-11-10 18:35:08.105 Error: Webserver: Failed authentication attempt, ignoring client request (remote addresses: 188.xxx.64.xxx)
2015-11-10 18:35:51.651 Error: Webserver: Failed authentication attempt, ignoring client request (remote addresses: 188.xxx.64.xxx)
2015-11-10 18:35:51.811 Error: Webserver: Failed authentication attempt, ignoring client request (remote addresses: 188.xxx.64.xxx)
2015-11-10 18:36:00.245 Error: Webserver: Failed authentication attempt, ignoring client request (remote addresses: 188.xxx.64.xxx)
2015-11-10 18:36:00.365 Error: Webserver: Failed authentication attempt, ignoring client request (remote addresses: 188.xxx.64.xxx)
Code: Select all
.* Error: Failed login attempt from <HOST> for user '.*' !
Code: Select all
failregex = Error: Webserver: Failed authentication attempt, ignoring client request (remote addresses: <HOST>)
Code: Select all
failregex = Error: Webserver: Failed authentication attempt, ignoring client request \(remote addresses: <HOST>\)
Code: Select all
[DEFAULT]
ignoreip = 127.0.0.1/8 192.168.0.1/24
bantime = 3600
maxretry = 1
backend = auto
banaction = iptables-allports
mta = sendmail
protocol = all
port = all
chain = INPUT
action = route
[domoticz]
enabled = true
filter = domoticz
logpath = /var/log/domoticz.log
Code: Select all
# Fail2Ban configuration file FOR Domoticz Failed login
# Author: Egregius
[Definition]
failregex = Error: Failed login attempt from <HOST>
ignoreregex =
Code: Select all
[Definition]
actionban = ip route add <blocktype> <ip>
actionunban = ip route del <blocktype> <ip>
[Init]
blocktype = blackhole
Code: Select all
2015-11-11 13:37:18.117 Error: Failed login attempt from 178.145.160.129 for user 'test' !
Code: Select all
2015-11-11 13:37:20,439 fail2ban.actions: WARNING [domoticz] Ban 178.145.160.129
Code: Select all
Error: Webserver: Failed authentication attempt, ignoring client request (remote addresses: xxx.xx.xx.xx)
Code: Select all
failregex = .* Error: Failed login attempt from <HOST> for user '.*' !
Error: Webserver: Failed authentication attempt, ignoring client request (remote addresses: <HOST>)
I'm still having problems with this. When i try to lock myself, the hostname is still being added. I also tried it on a Ziggo business internet connection, the hostname (same as i see on http://ipinfo.io) is added to iptables. I just want the IP-address to be added, instead of the hostname. When i try to unban the hostname, it says it hasn't found anything. When i run the unban command with the IP-address, it works....!?ThinkPad wrote:I got it working The round brackets needed escaping btw (putting a backward slash in front of them, see the wiki for final regex).
However, i got some questions:
Under: http://domoticz.com/wiki/Automated_bann ... live_setup the original tutorial mentions an IP. In my case (testing over 3G), a hostname is added to the firewall blocklist.... (static.kpn.net). This is something that is problematic for unbanning, because for the unbanning command it needs an IP.
Some parameter that i haven't configured correctly?
For now i just used sudo iptables --flush fail2ban-domoticz, but that flushes the whole fail2ban-domoticz part of iptables i guess...
Code: Select all
WARNING 'findtime' not defined in 'ssh'. Using default value
WARNING 'findtime' not defined in 'dropbear'. Using default value
WARNING 'findtime' not defined in 'pam-generic'. Using default value
WARNING 'findtime' not defined in 'xinetd-fail'. Using default value
WARNING 'findtime' not defined in 'ssh-ddos'. Using default value
WARNING 'findtime' not defined in 'apache'. Using default value
WARNING 'findtime' not defined in 'apache-multiport'. Using default value
WARNING 'findtime' not defined in 'apache-noscript'. Using default value
WARNING 'findtime' not defined in 'apache-overflows'. Using default value
WARNING 'findtime' not defined in 'vsftpd'. Using default value
WARNING 'findtime' not defined in 'proftpd'. Using default value
WARNING 'findtime' not defined in 'pure-ftpd'. Using default value
WARNING 'findtime' not defined in 'wuftpd'. Using default value
WARNING 'findtime' not defined in 'postfix'. Using default value
WARNING 'findtime' not defined in 'couriersmtp'. Using default value
WARNING 'findtime' not defined in 'courierauth'. Using default value
WARNING 'findtime' not defined in 'sasl'. Using default value
WARNING 'findtime' not defined in 'dovecot'. Using default value
WARNING 'findtime' not defined in 'named-refused-tcp'. Using default value
WARNING 'filter' not defined in 'domoticz'. Using default value
ERROR /etc/fail2ban/filter.d/.conf and /etc/fail2ban/filter.d/.local do not exist
ERROR Unable to read the filter
ERROR Errors in jail 'domoticz'. Skipping...
Users browsing this forum: No registered users and 0 guests