C.W.K.
Stream
Lesson 03 of 14 · published

Fail2ban — Brute Force 자동 차단

~15 min · fail2ban, brute-force, linux, logwatching

Level 0Pinger
0 XP0/101 lessons0/12 achievements
0/150 XP to next level150 XP to go0% complete

Auth log 읽고 가해자 ban

Fail2ban 이 로그 파일에서 실패 로그인 signature 보고 방화벽 layer 에서 가해 IP 자동 차단. M 분 안 N 번 실패 후 IP 가 임시 ban. Key-only 인증 (brute-force 무의미하게 만듦) 있어도 fail2ban 이 auth log 의 노이즈 줄이고 slow-burn 공격 surface 감소.

기본 SSH jail

Fail2ban 이 battle-tested SSH jail 함께 옴. 보통 jail.local(절대 jail.conf X — 패키지 업그레이드 시 덮어씀) 에서 임계와 ban 기간만 override. maxretry, findtime, bantime, LAN 위한 ignoreip 설정.

Code

Linux 설치 및 설정·bash
# Install
sudo apt install fail2ban
sudo systemctl enable --now fail2ban

# Create local config (NEVER edit jail.conf directly)
sudo cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
sudo nano /etc/fail2ban/jail.local
jail.local 의 최소 SSH jail·ini
[sshd]
enabled  = true
port     = ssh
filter   = sshd
logpath  = /var/log/auth.log
maxretry = 3
findtime = 600        # within 10 minutes
bantime  = 3600       # ban for 1 hour
ignoreip = 127.0.0.1/8 192.168.1.0/24 100.64.0.0/10  # localhost + LAN + Tailscale
운영·bash
# Reload after editing
sudo systemctl restart fail2ban

# See banned IPs and stats
sudo fail2ban-client status sshd

# Manually unban (e.g., yourself after a typo storm)
sudo fail2ban-client set sshd unbanip 203.0.113.50

# Tail what fail2ban is seeing
sudo tail -f /var/log/fail2ban.log

External links

Exercise

통제하는 Linux 박스 (cloud VM 또는 homelab Linux) 에 fail2ban 설치하고 위 SSH jail 셋업. 24 시간 후 sudo fail2ban-client status sshd 돌려 누적 ban 카운트 봐. Public-facing 서버가 보통 매일 수십 ~ 수백 ban 쌓아. Key-only 인증 있어도 — 네 IP 가 끄는 백그라운드 스캔 양의 진짜 측정.

Progress

Progress is local-only — sign in to sync across devices.
이 페이지에서 버그를 발견하셨거나 피드백이 있으세요?문제 신고

댓글 0

🔔 답글 알림 (로그인 필요)
로그인댓글을 남기려면 로그인해 주세요.

아직 댓글이 없어요. 첫 댓글을 남겨보세요.