firewall
БесплатноБез исполняемых скриптовНе проверенLinux firewall configuration skill: UFW (Uncomplicated Firewall), iptables, nftables fundamentals, and fail2ban intrusion prevention. USE WHEN: - Setting up…
от claude-dev-suite★ 51 звезда на GitHubОб этом скилле
Firewall Configuration — UFW, iptables, nftables, fail2ban
Defence-in-Depth Model
A production server should have at least two layers:
- Cloud security group — controls traffic at the hypervisor/VPC level; blocks reach the host NIC. Cheapest filter; stateful by default. Configure this first.
- Host-based firewall (UFW / iptables / nftables) — applied by the kernel; catches port scans, limits rate of connections, enforces policy if security group is misconfigured.
- fail2ban — bans IP addresses that show malicious behaviour patterns (too many auth failures, suspicious request patterns) by inserting iptables rules.
UFW — Full Server Lockdown Sequence
Run this sequence on a fresh server before exposing it to the internet. Keep your current SSH session open while testing — UFW changes take effect immediately.
# 1. Install UFW (usually pre-installed on Ubuntu)
sudo apt-get install -y ufw
# 2. Set default policies — deny all inbound, allow all outbound
sudo ufw default deny incoming
sudo ufw default allow outgoing
# 3. Allow SSH BEFORE enabling UFW (otherwise you lock yourself out)
sudo ufw allow 22/tcp comment 'SSH'
# Or limit SSH to your own IP range:
sudo ufw allow from 203.0.113.0/24 to any port 22 proto tcp comment 'SSH from office'
# 4. Allow web traffic
sudo ufw allow 80/tcp comment 'HTTP'
sudo ufw allow 443/tcp comment 'HTTPS'
# 5. Allow other application ports as needed
sudo ufw allow 5432/tcp comment 'PostgreSQL — app subnet only'
# Better: restrict by source IP
sudo ufw allow from 10.0.1.0/24 to any port 5432 proto tcp comment 'PostgreSQL internal'
# 6. Enable UFW (prompts for confirmation)
sudo ufw enable
# 7. Verify status
sudo ufw status verbose
sudo ufw status numbered # Shows rule numbers for easier deletion
UFW Common Operations
# Remove a rule by number (get numbers from 'ufw status numbered')
sudo ufw delete 5
# Remove a rule by specification (exact match)
sudo ufw delete allow 80/tcp
# Rate-limit a port (UFW built-in: block IPs that connect > 6 times in 30s)
sudo ufw limit 22/tcp comment 'Rate-limit SSH brute force'
# Allow by named service (reads /etc/services)
sudo ufw allow smtp
sudo ufw allow 'Nginx Full' # Application profile from /etc/ufw/applications.d/
# List available application profiles
sudo ufw app list
sudo ufw app info 'Nginx Full'
# Logging levels: off, low, medium, high, full
sudo ufw logging medium
# Reload (re-read rules without disabling)
sudo ufw reload
# Disable UFW completely
sudo ufw disable
# Reset to defaults (removes all rules)
sudo ufw reset
# Check UFW log
tail -f /var/log/ufw.log
journalctl -k | grep UFW
iptables Fundamentals
UFW is a frontend to iptables. For advanced use cases (NAT, custom chains), work directly with iptables.
Chains and Tables
| Table | Chains | Purpose |
|---|---|---|
filter (default) |
INPUT, FORWARD, OUTPUT | Accept / drop / reject packets |
nat |
PREROUTING, POSTROUTING, OUTPUT | Address and port translation |
mangle |
All five chains | Modify packet headers (TTL, QoS marks) |
raw |
PREROUTING, OUTPUT | Bypass connection tracking |
Common iptables Commands
# List all rules with line numbers and counters
sudo iptables -L -n -v --line-numbers
sudo iptables -t nat -L -n -v # NAT table
# Allow established/related connections (essential — add before deny rules)
sudo iptables -A INPUT -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
sudo iptables -A INPUT -i lo -j ACCEPT # Allow loopback
# Allow specific port
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT
# Block a specific IP
sudo iptables -I INPUT -s 192.0.2.100 -j DROP
# Reject with ICMP (polite; informs sender)
sudo iptables -A INPUT -p tcp --dport 25 -j REJECT --reject-with tcp-reset
# Limit connection rate (SYN flood protection)
sudo iptables -A INPUT -p tcp --syn --dport 80 \
-m connlimit --connlimit-above 20 -j REJECT
# Save rules persistently (package: iptables-persistent)
sudo apt-get install -y iptables-persistent
sudo netfilter-persistent save # Saves to /etc/iptables/rules.v4 and rules.v6
# Restore saved rules
sudo netfilter-persistent reload
# Flush all rules (dangerous — default policy must be ACCEPT first)
sudo iptables -P INPUT ACCEPT
sudo iptables -F
sudo iptables -X
NAT — MASQUERADE (WireGuard / VPN Gateway)
# Enable IP forwarding (also set in sysctl.d)
echo 'net.ipv4.ip_forward = 1' | sudo tee /etc/sysctl.d/50-ip-forward.conf
sudo sysctl -p /etc/sysctl.d/50-ip-forward.conf
# Masquerade VPN traffic going out via eth0
# (wg0 = WireGuard interface; eth0 = public internet interface)
sudo iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
# Allow forwarded traffic from VPN
sudo iptables -A FORWARD -i wg0 -j ACCEPT
sudo iptables -A FORWARD -o wg0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
sudo netfilter-persistent save
NAT — DNAT (Po
Установить firewall в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
ReadGrepGlobWriteEditBashFAQ
Что делает скилл firewall?
Linux firewall configuration skill: UFW (Uncomplicated Firewall), iptables, nftables fundamentals, and fail2ban intrusion prevention. USE WHEN: - Setting up UFW on a new server (default deny-in, allow-out, selective port opens) - Configuring rate limiting and per-IP connection limits with UFW or iptables - Installing and tuning fail2ban for SSH, Nginx, and custom application jails - Writing iptables NAT rules (MASQUERADE for WireGuard/VPN, DNAT for port forwarding) - Diagnosing lockouts, fail2ban false positives, or blocked legitimate traffic - Setting up cloud security groups as the first layer of defence DO NOT USE FOR: - Application-level authentication / authorisation (use authentication skill) - SSL/TLS certificate management (use ssl-tls skill) - Kubernetes NetworkPolicy rules (use kubernetes skill) - WAF (Web Application Firewall) rules — Nginx rate limiting covers basic cases
Как установить скилл firewall?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл firewall запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic