Публикации с меткой ‘sip’

защита sip от перебора

20 октября 2010 Нет комментариев


fail2ban — достаточно удобный способ защиты сервисов от перебора паролей и других атак на основе анализа log файлов приложений.
представляет собой набор скриптов на phyton

имеется в портах freebsd и пекетах debian,ubuntu

настройки специфичные для asterisk:

The contents of /etc/fail2ban/filter.d/asterisk.conf should be the following:


# Fail2Ban configuration file
# $Revision: 250 $


# Read common prefixes. If any customizations available -- read them from
# common.local
#before = common.conf


#_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

failregex = NOTICE.* .*: Registration from '.*' failed for '<HOST>' - Wrong password
NOTICE.* .*: Registration from '.*' failed for '<HOST>' - No matching peer found
NOTICE.* .*: Registration from '.*' failed for '<HOST>' - Username/auth name mismatch
NOTICE.* .*: Registration from '.*' failed for '<HOST>' - Device does not match ACL
NOTICE.* .*: Registration from '.*' failed for '<HOST>' - Peer is not supposed to register
NOTICE.* .*: Registration from '.*' failed for '<HOST>' - ACL error (permit/deny)
NOTICE.* <HOST> failed to authenticate as '.*'$
NOTICE.* .*: No registration for peer '.*' \(from <HOST>\)
NOTICE.* .*: Host <HOST> failed MD5 authentication for '.*' (.*)
NOTICE.* .*: Failed to authenticate user .*@<HOST>.*

# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
ignoreregex =

Next edit /etc/fail2ban/jail.conf to include the following section so that it uses the new filter. This does a 3-day ban on the IP that performed the attack. It is recommend to set the bantime in the [DEFAULT] section so if affects all attacks. It is also recommend to turn on an iptables ban for ssh, httpd/apache, and ftp if they are running on the system. Be sure to edit the sendmail-whois action to send notifications to an appropriate address:

enabled  = true
filter   = asterisk
action   = iptables-allports[name=ASTERISK, protocol=all]
mail-whois[name=ASTERISK, dest=root, sender=sip3@unetcom.ru]
logpath  = /var/log/asterisk/full
maxretry = 4
bantime = 259200

To change this format, open /etc/asterisk/logger.conf and add the following line under [general] section (You may have to create this before the [logfiles] section). This causes the date and time to be formatted as Year-Month-Day Hour:Minute:Second, [2008-10-01 13:40:04] is an example.

dateformat=%F %T

для применения изменений перезапустим логгер
asterisk -rx "logger reload"

Categories: Asterisk, Linux Tags: ,

Установка и настройка Asterisk 1.6 + PostgreSQL на Debian

9 октября 2009 Нет комментариев
Categories: Asterisk Tags: , , ,

Asterisk RealTime (вместо конфигов БД)

9 октября 2009 Нет комментариев
Categories: Asterisk Tags: , , ,