​fail2ban À¸·Î ÀÏÁ¤È½¼ö ÀÌ»óÀÇ Á¢¼Ó ½ÇÆÐ IP Â÷´Ü

   Á¶È¸ 8414   Ãßõ 1    

http://ehostidc.co.kr/center/EH050402.php?no=279270&page=5&choose=tit¡¦ (398)
https://blog.naver.com/goethe1/221607503878 (440)

fail2ban 으로 일정횟수 이상의 접속 실패 IP 차단

CentOS 7 환경

1. 저정소 추가 

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

2. 패키지 설치

# yum --enablerepo epel install fail2ban


# systemctl enable fail2ban
# systemctl restart fail2ban

3. 환경 설정

# vi /etc/fail2ban/jail.conf

# 접속 차단 예외 IP
ignoreip = 127.0.0.1/8 192.168.10.0/24

# 접속 차단 시간 default 600초
bantime = 600

# findtime(초) 내에 maxretty 횟수만큼 인증 실패시 차단
findtime = 60
maxretry = 5

4. 별도 설정 파일 ( 별도 파일 생성을 통한 관리)

# vi /etc/fail2ban/jail.local 
[DEFAULT]
bantime = 3600
[sshd]
enabled = true

5. 서비스 확인

a. iptables 룰셋 확인





b. 전체 상태

# fail2ban-client status

c. 서비스별 상태

# fail2ban-client status sshd

d. ipset 설정(차단) 확인

# ipset --list

e. fail2ban 로그 확인

awk "($(NF-1) = /Ban/){print $NF}" /var/log/fail2ban.log | sort | uniq -c | sort -n





ªÀº±Û Àϼö·Ï ½ÅÁßÇϰÔ.
À¯ÀÍÇÑ ³»¿ë °¨»çÇÕ´Ï´Ù.
CentOS ¿¡´Ù  fail2ban »ç¿ëÁßÀ̱ä ÇÏÁö¸¸, Ãʺ¸¶ó ¾îÂîÇÒ ÁÙ ¸ð¸£´Â ÂüÀ̾ú´Âµ¥, ¹®ÀÇ ±Û Çѹø ¿Ã·Áº¾´Ï´Ù.
messages ·Î±×¿¡ º¸¸é ¾Æ·¡¿Í °°ÀÌ smtp ½Ãµµ ·Î±×°¡ ÀÜ¶à ½×À̰í ÀÖ½À´Ï´Ù.
¼ÒÀÎÀÇ °æ¿ì À¥¼­¹ö¿¡¼­´Â À¥½ÎÀÌÆ®¸¸ °¡µ¿Çϰí, dns ¼­¹ö´Â ¿ÜºÎÀÇ À¥dns ÀÌ¿ëÇϰí, À̸ÞÀÏ ¼­¹ö´Â Office365 À̸ÞÀÏ smtp¸¦ ÀÌ¿ëÇÕ´Ï´Ù.
±×·¯¸é ÀúÀÇ À¥¼­¹ö¿¡¼­´Â À¥½ÎÀÌÆ®¿¡¼­ »ý»êÇÏ¿© ¹ß¼ÛÇÏ´Â À̸ÞÀÏ¿¡ ´ëÇÑ ¹ß¼Û¸¸ ½ÇÇàÇÏ¸é µÇ°í, ¿ÜºÎÀÇ Á¦ 3ÀÚ ¸ÞÀÏÀ» ¼ö½ÅÇÒ Çʿ䰡 ¾ø°í ¸±·¹ÀÌÇÒ Çʿ䵵 ¾ø´Âµ¥, Á¦°¡ ¹¹ ºÒÇÊ¿äÇÑ ¼­ºñ½º¸¦ ½ÇÇàÇϰí ÀÖ´Â °ÍÀÏÁö¿ä?

Postfix ´Â ½ÇÇàÇϰí Çϰí, BIND ¿Í  Dovecot IMAP/POP3 ´Â ÁßÁö½ÃÄѵΰí ÀÖ½À´Ï´Ù.
fail2ban À» ½ÇÇàÇϰí ÀÖ°í, iptables°ú host.deny¿¡ ¸ðµç ¿ÜºÎ IP¿¡ ´ëÇØ¼­ sshd, ftpd,mysqld Á¢¼Ó Â÷´ÜÇØµÎ°í ÀÖ½À´Ï´Ù. 

Postfix ¼³Á¤¿¡ ¹º°¡¸¦ ÇØÁÖ¾î¾ß ÇÏ´ÂÁö, fail2ban¿¡ ¹º°¡¸¦ ÇØÁÖ¾î¾ß ÇÏ´ÂÁö ¾Ë ¼ö ÀÖÀ¸¸é ÁÁ°Ú½À´Ï´Ù.

¹¹µç Á¶¾ðÀ» Á» ÇØÁÖ½Ã¸é °í¸¿°Ú½À´Ï´Ù.

Aug 18 01:16:48 huso saslauthd[3869]: do_auth        : auth failure: [user=foo@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:17:00 huso saslauthd[3865]: do_auth        : auth failure: [user=settle@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:17:03 huso saslauthd[3868]: do_auth        : auth failure: [user=xxxx@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:17:04 huso saslauthd[3866]: do_auth        : auth failure: [user=user] [service=smtp] [realm=] [mech=pam] [reason=PAM auth error]
Aug 18 01:17:05 huso saslauthd[3865]: do_auth        : auth failure: [user=mold@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:17:27 huso saslauthd[3867]: do_auth        : auth failure: [user=mozart@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:17:28 huso saslauthd[3868]: do_auth        : auth failure: [user=foobar@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:17:35 huso saslauthd[3865]: do_auth        : auth failure: [user=tomsk@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:17:40 huso saslauthd[3866]: do_auth        : auth failure: [user=sonia@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:17:42 huso saslauthd[3869]: do_auth        : auth failure: [user=murray@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:18:03 huso saslauthd[3865]: do_auth        : auth failure: [user=house@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:18:07 huso saslauthd[3867]: do_auth        : auth failure: [user=foobet@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:18:10 huso saslauthd[3868]: do_auth        : auth failure: [user=oshima@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:18:19 huso saslauthd[3869]: do_auth        : auth failure: [user=mall@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:18:28 huso saslauthd[3866]: do_auth        : auth failure: [user=pund@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:18:41 huso saslauthd[3867]: do_auth        : auth failure: [user=rosie@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:18:46 huso saslauthd[3869]: do_auth        : auth failure: [user=overseas@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]
Aug 18 01:18:55 huso saslauthd[3866]: do_auth        : auth failure: [user=foodpolis@or.kr] [service=smtp] [realm=or.kr] [mech=pam] [reason=PAM auth error]


PDS
Á¦¸ñPage 26/80
2014-05   5846792   Á¤ÀºÁØ1
04-15   38246   UPDF
2022-05   12227   Á¦¿ÂÇÁ·Î
2016-03   12247   Ä«·ÎÄ«·Î
2022-05   12249   È­Á¤Å¥»ï
2015-12   12257   ¼Ò¸Á»ç¶û71
2021-02   12282   ±îÄ¡»ê°³²ÜÅÊ
2023-12   12298   ¹Ú¹®Çü
2022-05   12299   PCMaster
2018-06   12300   ÀüÁ÷P¿¬±¸¿ø
2024-01   12304   Á¦°¥±âõ
2015-12   12326   ¼Ò¸Á»ç¶û71
2015-12   12370   ¼Ò¸Á»ç¶û71
2018-10   12371   ȲÁø¿ì
2018-06   12413   ÀÌÁ¾Çöoph
2015-12   12427   ¼Ò¸Á»ç¶û71
2024-01   12452   ±è°¡ÇǽÃ
2017-07   12511   ¹Ú¼öÈ«84Æ÷Ç×
2017-06   12524   ¼º±â»ç
2022-05   12544   ±èÀå¿ì
2015-12   12548   ¼Ò¸Á»ç¶û71
2017-10   12556   theÃ̳ð