System information
$ sudo apt-get install postfix
To install Postfix on CentOS, use this command:
$ sudo yum install postfix
To test the installation of your MTA, you can send a quick email using mutt. To install
it, use the same installation commands as given for installing Postfix, but substitute
mutt for the package name. Then run the following commands to test the MTA:
$ echo "Just testing." > email.txt
$ mutt -s "Testing" youraddress@shifteight.org < email.txt
Configuration
The first file that must be set up is the Asterisk logging configuration file. Here are the
contents of /etc/asterisk/logger.conf on a working system. Ensure that you at least have
dateformat and messages set, as those are required for Fail2ban:
[general]
dateformat = %F %T
[logfiles]
console => notice,warning,error,debug
messages => notice,warning,error
The next configuration file that must be created is the one that teaches Fail2ban what
to watch out for in Asterisk log files. Place the following contents in a new file
called /etc/fail2ban/filter.d/asterisk.conf:
[INCLUDES]
# Read common prefixes. If any customizations available -- read them from
# common.local
#before = common.conf
[Definition]
#_daemon = asterisk
# 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>\S+)
# Values: TEXT
#
# *** All lines below should start with NOTICE
#
failregex = NOTICE.* .*: Registration from '.*' failed for '<HOST>'
# - Wrong password
Fail2ban | 569