Fail2ban: Installation, Configuration, and Manual Ban/Unban
How to install and configure Fail2ban on Linux, and manually ban/unban IPs and check status.
June 17, 2026
Fail2ban: Installation, Configuration, and Manual Ban/Unban
Fail2ban은 로그 파일을 모니터링하여 반복적인 로그인 실패, 포트 스캔 등 악의적인 접근 패턴을 감지하면 해당 IP를
iptables 또는 nftables 방화벽 규칙에 자동으로 추가해 차단하는 보안 도구입니다.SSH 무차별 대입 공격(brute-force)을 막는 데 가장 많이 사용됩니다.
1. Install Fail2ban
Install Fail2bansh
2. Configure jail.local
jail.conf는 업데이트 시 덮어써질 수 있으므로, 반드시 jail.local을 별도로 만들어 설정합니다.
Create jail.local from default configsh
[DEFAULT] 섹션에서 공통 설정을, [sshd] 섹션에서 SSH 전용 설정을 지정합니다./etc/fail2ban/jail.localsh
3. Start & Enable Service
Start and enable Fail2ban servicesh
4. Check Status
전체 jail 목록과 각 jail의 차단 현황을 확인합니다.
Check all jail statussh
특정 jail의 상세 상태(차단된 IP 목록 포함)를 확인합니다.
Check sshd jail statussh
5. Manual Ban
특정 IP를 수동으로 즉시 차단합니다.
Manually ban an IPsh
6. Manual Unban
차단된 IP를 수동으로 해제합니다.
Manually unban an IPsh
7. Reload Configuration
jail.local 수정 후 서비스를 재시작하지 않고 설정만 다시 불러옵니다.Reload Fail2ban configurationsh
Command Summary
| 명령어 | 설명 |
|---|---|
fail2ban-client status | 전체 jail 목록 확인 |
fail2ban-client status sshd | 특정 jail 상태 및 차단 IP 목록 확인 |
fail2ban-client set sshd banip <IP> | IP 수동 차단 |
fail2ban-client set sshd unbanip <IP> | IP 차단 해제 |
fail2ban-client reload | 설정 리로드 |
systemctl restart fail2ban | 서비스 재시작 |