Hi I have just installed my new server that runs Ubuntu 22.04 (It's hosted with hetzner.de). But I have a problem with fail2ban. When my server boot, fail2ban make some errors and don't send mails. If I run "systemctl status fail2ban" it gives me this error: If I then run "systemctl restart fail2ban" and then "systemctl status fail2ban" its working fine.. I hope you can help me out here.. If you need any info.. Just say it, and i will post it. EDIT: I use ssmtp as mail relay, that sending to mailgun. - I have attached my jail.local and my fail2ban.conf
The first error message looks like fail2ban starts too soon, before name resolving works. Have you modified the startup file or files? Are you using systemd or modified Ubuntu to use some other startup script handler for booting? Maybe try to debug the booting sequence, or undo your changes if you have done any for the booting.
Hi @Taleman Thanks for your reply. Im really appreciated it. I think you are right about the error. But how can fix it? I have followed this guide: https://www.howtoforge.com/how-to-install-fail2ban-on-ubuntu-22-04/ I have not changed anything with the boot config. It's very stange! Regards Thomas
Hi agian I fixed the error by open "/lib/systemd/system/fail2ban.service" and put this code in it: ExecStartPre=/bin/sleep 30 Thanks for the help.
Uhh that is quiet hacky. Your way is working but it is not a good practice to just wait x seconds because we assume network is present then. Use the builit "After" feature is much more reliable. Fix the systemd unit like this: There is a line in the unitfile under the "[Unit]" section which starts with "After=", just add "After=network-online.target ..." and you should be good to go. don't forget the systemctl daemon-reload afterwards