Fail2ban - help with configuration

Good Morning everyone,

New here and first time poster, hope you can point me in the correct direction with help on getting it configured and sorted.

I have recently installed nextcloud (manual install) on ubuntu server, all is configured and appears to be working fine, however I have installed fail2ban but struggling to configure it and get it running, can anyone please help and point me in the correct direction?

Using V28.2 of nextcloud.

I have managed to install fail2ban by doing the command: sudo apt install fail2ban

This installed without any issue but then when I tried to check the service status it wasn’t running and I didn’t understand the error or where to start troubleshooting.

Any help would be massively apprecaited!

Thanks in advance!

What’s the output of:

sudo journalctl -u fail2ban
1 Like

Hi @qwerty573 ,

Have you read the β†’ manual section about fail2ban ← ?

… indicates that you are running an Ubuntu or Debian.

What is the output of

journalctl -xeu fail2ban.service

ernolf

Hi bb77,

Thank you for your help so far.

The output is:

Jan 31 09:58:16 DOMAIN systemd[1]: Started Fail2Ban Service.
Jan 31 09:58:16 DOMAIN fail2ban-server[2455]: ERROR: While reading from '/etc/fail2ban/fail2ban.local' [line 88]: section 'Definition' already exists
Jan 31 09:58:16 DOMAIN systemd[1]: fail2ban.service: Main process exited, code=exited, status=255/EXCEPTION
Jan 31 09:58:16 DOMAIN systemd[1]: fail2ban.service: Failed with result 'exit-code'.
Jan 31 10:04:34 DOMAIN systemd[1]: Started Fail2Ban Service.
Jan 31 10:04:34 DOMAIN fail2ban-server[2493]: ERROR: While reading from '/etc/fail2ban/fail2ban.local' [line 88]: section 'Definition' already exists
Jan 31 10:04:34 DOMAIN systemd[1]: fail2ban.service: Main process exited, code=exited, status=255/EXCEPTION
Jan 31 10:04:34 DOMAIN systemd[1]: fail2ban.service: Failed with result 'exit-code'.
-- Boot 34703501791e4b95a202693e3eb1cb33 --
Jan 31 16:42:59 DOMAIN systemd[1]: Started Fail2Ban Service.
Jan 31 16:42:59 DOMAIN fail2ban-server[3015]: 2024-01-31 16:42:59,660 fail2ban                [3015]: ERROR   Failed during configuration: Have not fo>
Jan 31 16:42:59 DOMAIN fail2ban-server[3015]: 2024-01-31 16:42:59,660 fail2ban                [3015]: ERROR   Async configuration of server failed
Jan 31 16:42:59 DOMAIN systemd[1]: fail2ban.service: Main process exited, code=exited, status=255/EXCEPTION
Jan 31 16:42:59 DOMAIN systemd[1]: fail2ban.service: Failed with result 'exit-code'.
~
~
~
~
~
~
~
~
~
lines 1-14/14 (END)

I have changed my domain name to just reflect DOMAIN in the output.

This doesn’t mean a great deal to myself, but hopefully will to you?!

Thanks again!

Hi Ernolf,

Yes I did read the guide but it wasn’t as easy as just following it…

I am using ubuntu server.

I’ve done the command and got the following out:

Subject: A start job for unit fail2ban.service has finished successfully
β–‘β–‘ Defined-By: systemd
β–‘β–‘ Support: http://www.ubuntu.com/support
β–‘β–‘ 
β–‘β–‘ A start job for unit fail2ban.service has finished successfully.
β–‘β–‘ 
β–‘β–‘ The job identifier is 2038.
Jan 31 16:42:59 DOMAIN fail2ban-server[3015]: 2024-01-31 16:42>
Jan 31 16:42:59 DOMAIN fail2ban-server[3015]: 2024-01-31 16:42>
Jan 31 16:42:59 DOMAIN systemd[1]: fail2ban.service: Main proc>
β–‘β–‘ Subject: Unit process exited
β–‘β–‘ Defined-By: systemd
β–‘β–‘ Support: http://www.ubuntu.com/support
β–‘β–‘ 
β–‘β–‘ An ExecStart= process belonging to unit fail2ban.service has exited.
β–‘β–‘ 
β–‘β–‘ The process' exit code is 'exited' and its exit status is 255.
Jan 31 16:42:59 DOMAIN systemd[1]: fail2ban.service: Failed wi>
β–‘β–‘ Subject: Unit failed
β–‘β–‘ Defined-By: systemd
β–‘β–‘ Support: http://www.ubuntu.com/support
β–‘β–‘ 
β–‘β–‘ The unit fail2ban.service has entered the 'failed' state with result 'exit-c>
lines 49-71/71 (END)

Thanks so much in advance!

Jan 31 10:04:34 DOMAIN fail2ban-server[2493]: ERROR: While reading from '/etc/fail2ban/fail2ban.local' [line 88]: section 'Definition' already exists

It seems that there are two [Definition] sections in the file /etc/fail2ban/fail2ban.local. The section on line 88 in the file probably already exists elswhere in the file. Did you create or change that file manually?

1 Like

The lines are truncated because of the pager output.

An output without pager would provide more information:

journalctl --no-pager -xu fail2ban.service | tail -n 30

ernolf