config f2b for Ubuntu or Debian

This commit is contained in:
Matthew Saunders Brown 2024-06-14 16:05:30 -07:00
parent e4e5c41bbc
commit 302d1e9546
5 changed files with 11 additions and 2 deletions

View File

@ -2,4 +2,4 @@
enabled = true enabled = true
port = imap2,imap3,imaps,pop3,pop3s port = imap2,imap3,imaps,pop3,pop3s
filter = dovecot filter = dovecot
logpath = /var/log/mail.log tail

View File

@ -2,6 +2,7 @@
enabled = true enabled = true
port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s,submission port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s,submission
filter = exim-hard filter = exim-hard
backend = auto
logpath = /var/log/exim4/rejectlog tail logpath = /var/log/exim4/rejectlog tail
maxretry = 1 maxretry = 1
bantime = 86400 bantime = 86400

View File

@ -3,6 +3,7 @@ enabled = true
port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s,submission port = smtp,ssmtp,imap2,imap3,imaps,pop3,pop3s,submission
filter = exim-ratelimit filter = exim-ratelimit
action = mail-ratelimit action = mail-ratelimit
backend = auto
logpath = /var/log/exim4/rejectlog tail logpath = /var/log/exim4/rejectlog tail
maxretry = 1 maxretry = 1
findtime = 60 findtime = 60

View File

@ -2,4 +2,5 @@
enabled = true enabled = true
port = smtp,465,submission port = smtp,465,submission
filter = exim filter = exim
backend = auto
logpath = /var/log/exim4/rejectlog tail logpath = /var/log/exim4/rejectlog tail

View File

@ -129,7 +129,7 @@ install --owner=Debian-exim --group=Debian-exim --mode=640 /dev/null /etc/exim4/
cp etc/exim4/* /etc/exim4/ cp etc/exim4/* /etc/exim4/
if [ $os_codename = jammy ]; then if [ $os_codename = jammy ]; then
cp /etc/exim4/exim4-jammy.conf /etc/exim4/exim4.conf cp /etc/exim4/exim4-jammy.conf /etc/exim4/exim4.conf
elif [ $os_codename != bookworm ]; then elif [ $os_codename = bookworm ]; then
cp /etc/exim4/exim4-bookworm.conf /etc/exim4/exim4.conf cp /etc/exim4/exim4-bookworm.conf /etc/exim4/exim4.conf
else else
echo "WARNING: Unexpected OS codename. This should never happen due to previous checks." echo "WARNING: Unexpected OS codename. This should never happen due to previous checks."
@ -217,6 +217,12 @@ fi
if [[ -d /etc/fail2ban/ ]]; then if [[ -d /etc/fail2ban/ ]]; then
chmod 644 etc/fail2ban/*/*.conf chmod 644 etc/fail2ban/*/*.conf
cp -a etc/fail2ban/* /etc/fail2ban/ cp -a etc/fail2ban/* /etc/fail2ban/
if [ $os_codename = bookworm ]; then
echo "backend = systemd" >> /etc/fail2ban/jail.d/dovecot.conf
elif [ $os_codename = jammy ]; then
echo "backend = auto" >> /etc/fail2ban/jail.d/dovecot.conf
echo "logpath = /var/log/mail.log tail" >> /etc/fail2ban/jail.d/dovecot.conf
fi
else else
echo echo
echo "fail2ban not installed, skipping fail2ban email configs." echo "fail2ban not installed, skipping fail2ban email configs."