Linux Centos fail2ban
설치여부 확인
rpm -qa | grep fail2ban
Test Environment
- HostUs KVM VPS
- CentOS Linux release 7.2.1511 64 bit
1. Install
# yum install epel-release
# yum install fail2ban
2. Modify config
# vi /etc/fail2ban/jail.conf
[sshd]
enabled = true
3. Start
# systemctl start fail2ban
4. Ensure starts automatically at system start
# systemctl enable fail2ban
5. View status
# fail2ban-client status
# cat /var/log/fail2ban.log* | grep "] Ban" | awk '{print $NF}' | sort | uniq -c | sort -
----------------------------------------------------------------------------------------
ignoreip = 127.0.0.1/8 # 로컬 접속은 차단 예외
bantime = 600 # 60초
maxretry = 3 # 3번 이상 접속 못하는 IP 차단
3. Restart Demon
# /etc/init.d/fail2ban restart
4. Check Log
# vi /var/log/auth.log