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

Firewall 기초

~15 min · ufw, pf, firewall, default-deny

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

Default deny, 필요한 거 allow

옳은 방화벽 자세 단순 — 디폴트로 모든 inbound 거부, 필요한 specific 포트만 allow. 그 외는 swiss cheese 추론. Key-only SSH + fail2ban + 알려진 출처로 scope 된 방화벽 = 실용 공격 surface 99% 제거.

Linux 의 ufw, macOS 의 pf

Linux ufw (Uncomplicated Firewall) 가 iptables/nftables 의 친근한 front-end. macOS 가 BSD 파생 pf packet filter 와 함께; GUI "Application Firewall" 이 별도, 더 약한 layer. Fleet 엔 OS 별 host 레벨 방화벽 관리 + LAN/Tailnet 경계를 추가 perimeter 로 신뢰 패턴.

Code

ufw — Linux·bash
# Install (often preinstalled)
sudo apt install ufw

# Default policy: deny in, allow out
sudo ufw default deny incoming
sudo ufw default allow outgoing

# Allow SSH (replace with your real port)
sudo ufw allow 2222/tcp

# Or — only allow SSH from a specific subnet
sudo ufw allow from 192.168.1.0/24 to any port 2222 proto tcp

# Allow common things
sudo ufw allow 80/tcp     # HTTP
sudo ufw allow 443/tcp    # HTTPS

# Enable
sudo ufw enable

# Inspect
sudo ufw status verbose
sudo ufw status numbered

# Remove a rule by number
sudo ufw delete 5
pf — macOS·bash
# Edit /etc/pf.conf (start from the existing template)
# Add rules for your scenario, e.g.:
#   block in all
#   pass in proto tcp from 192.168.1.0/24 to any port 22
#   pass in proto tcp from 100.64.0.0/10 to any port 22

# Load and enable
sudo pfctl -f /etc/pf.conf
sudo pfctl -e

# Inspect
sudo pfctl -s rules
sudo pfctl -sa | head -40

# Disable (testing only)
sudo pfctl -d

External links

Exercise

Linux 서버에서 default deny + LAN 대역과 Tailnet 에서만 ssh allow 의 ufw 셋업. sudo ufw status verbose 가 policy 보여주는지 확인. 외부 네트워크 (폰 tethering) 에서 22 SSH 도달 불가 확인. LAN 또는 Tailscale 로 SSH 여전히 동작 확인. 그게 실제 production 자세.

Progress

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

댓글 0

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

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