맛집 여행 캠핑 일상 생활

[CentOS] 7.x fail2ban 설치 및 설정 방법 본문

IT이야기

[CentOS] 7.x fail2ban 설치 및 설정 방법

영은파더♥ 2020. 9. 24. 17:18

Brute force 공격에 대비하는 여러가지 방법 중에 하나인 fail2ban 을 설치하는 방법이 있습니다.

아래의 방법대로 설치하면 됩니다.

yum -y install fail2ban fail2ban-systemd whois

cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

vi /etc/fail2ban/jail.local
ignoreip = 127.0.0.1/8 192.168.1.0/24
bantime  = 48h
findtime  = 2h
maxretry = 5
backend = polling
destemail = root@localhost
sender = root@localhost
mta = sendmail

sed -i '/^\[apache/a\enabled\ =\ true' /etc/fail2ban/jail.local

systemctl enable fail2ban
systemctl start fail2ban

우선 인터넷에서 자료를 취합해서 위와 같이 설정하고 맛보기만 해봐서 제대로 작동되는지의 여부를 잘 모르겠네요~

기능상 버그라던가 이런 내용이 검색된게 없어서 설치하고 상황을 지켜봐야겠습니다.

fail2ban-client status apache-auth
fail2ban-client status apache-badbots
fail2ban-client status apache-botsearch
fail2ban-client status apache-fakegooglebot
fail2ban-client status apache-modsecurity
fail2ban-client status apache-nohome
fail2ban-client status apache-noscript
fail2ban-client status apache-overflows
fail2ban-client status apache-shellshock



[root@localhost ~]# fail2ban-client status apache-auth
Status for the jail: apache-auth
|- Filter
|  |- Currently failed: 4
|  |- Total failed:     99
|  `- File list:        /var/log/httpd/www.example.com-error_log
`- Actions
   |- Currently banned: 3
   |- Total banned:     3
   `- Banned IP list:   89.248.xxx.11 142.44.xxx.104 140.xxx.0.107

하루가 지나서 확인해보니 apache-auth 에서 3개의 ip 가 밴 당했네요~

아이피를 확인해 보니 외국이더군요~

cat /var/log/fail2ban.log | grep Ban 으로 확인하는게 더 좋을 것 같습니다.

 

 

Trackback : | Comments :