diff --git a/x-ui.sh b/x-ui.sh index e9d74a9a5..7213ff3e2 100644 --- a/x-ui.sh +++ b/x-ui.sh @@ -2505,9 +2505,14 @@ create_iplimit_jails() { # Uncomment 'allowipv6 = auto' in fail2ban.conf sed -i 's/#allowipv6 = auto/allowipv6 = auto/g' /etc/fail2ban/fail2ban.conf - # On Debian 12+ and Ubuntu 22.04+ fail2ban's default backend should be changed to systemd - if [[ ( "${release}" == "debian" && ${os_version} -ge 12 ) || ( "${release}" == "ubuntu" && ${os_version} -ge 2200 ) ]]; then - sed -i '0,/action =/s/backend = auto/backend = systemd/' /etc/fail2ban/jail.conf + # Debian 12+ / Ubuntu 22.04+ log sshd to the journal only; a jail.d override + # survives package upgrades. Only the stock 'backend = auto' is overridden. + if [[ ( "${release}" == "debian" && ${os_version} -ge 12 ) || ( "${release}" == "ubuntu" && ${os_version} -ge 2200 ) ]] && + sed -n '0,/action =/p' /etc/fail2ban/jail.conf | grep -q '^backend = auto'; then + cat << EOF > /etc/fail2ban/jail.d/3x-ipl-backend.conf +[DEFAULT] +backend = systemd +EOF fi cat << EOF > /etc/fail2ban/jail.d/3x-ipl.conf