SpecialistOff.NET / Вопросы / Статьи / Фрагменты кода / Резюме / Метки / Помощь / Файлы
НазадМетки: межсетевой экран syslog.conf bruteblock ipfw
Примечание
bruteblock не эффективен. Ниже даны таблицы блокировки:
00600 0 0 deny ip from table(1) to any 00700 310210 26126472 deny ip from table(2) to any
root # make -C /usr/ports/security/bruteblock/ install clean
Конфигурирование bruteblock файлами находящимися в директории /usr/local/etc/bruteblock/
Необходимо добавить следующую строку в файл /etc/syslog.conf:
Файл: /etc/syslog.conf
!* auth.info;authpriv.info |exec /usr/local/sbin/bruteblock -f /usr/local/etc/bruteblock/ssh.conf
и перезапустить syslogd.
Also you should add ipfw2 table and the corresponding deny rule. For example,
root # ipfw add deny ip from table(1) to any
Next, you'll want to setup periodical cleanup of ipfw2 table. Add following lines to /etc/rc.conf:
Файл: /etc/rc.conf
bruteblockd_enable="YES" bruteblockd_table="1" bruteblockd_flags="-s 5"
Запустить bruteblockd:
root # /usr/local/etc/rc.d/bruteblockd.sh start
See bruteblock(8) for more details.
Примечание: Для тестирования регулярных выражений используется pcretest
Файл: /usr/local/etc/bruteblock/ssh.conf
regexp = sshd.*(?:Illegal|Invalid) user \S+ from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) regexp1 = sshd.*Failed \S+ for (?:(?:illegal|invalid) user )?\S+ from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) regexp2 = sshd.*error: PAM: authentication error for (?:(?:illegal|invalid) user )\S+ from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) regexp3 = sshd.*Did not receive identification string from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}) regexp4 = sshd.*reverse mapping checking getaddrinfo for \S+ \[(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\] failed - POSSIBLE BREAK-IN ATTEMPT! regexp5 = sshd.*Received disconnect from (\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\: 11\: Bye Bye \[preauth\] # Number of failed login attempts within time before we block max_count = 4 # Time in seconds in which all failed login attempts must occur within_time = 60 # Time in seconds to block ip in firewall # 10 minutes reset_ip = 600 # IPFW table number to add "bad" hosts ipfw2_table_no = 1