Debian 防火墙策略指的是在 Debian 系统中,用来控制网络流量进出、保障系统安全的一套规则与配置方式。严格来说,Debian 本身没有独立的“防火墙程序”,而是依赖 Linux 内核的 netfilter/iptables 或 nftables,并通过工具来制定策略。
下面从概念 → 核心工具 → 常见策略示例 → 推荐做法来说明。
Debian 防火墙基于 Linux 内核 netfilter:
Debian 10 以后,默认更推荐 nftables。
直接操作内核规则,但较复杂:
iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A INPUT -j DROP
问题:
Debian 10+ 默认支持:
nft add table inet filter
nft add chain inet filter input { type filter hook input priority 0 \; }
优点:
Uncomplicated Firewall,Debian 官方仓库提供,适合服务器和桌面:
sudo apt install ufw
sudo ufw enable
示例策略:
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp
✅ 90% 的 Debian 用户推荐用 UFW
常见于 RHEL,Debian 不默认支持。
原则:默认拒绝 → 只放行必要端口
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow 22/tcp # SSH
sudo ufw allow 80/tcp # HTTP
sudo ufw allow 443/tcp # HTTPS
sudo ufw enable
sudo ufw allow from 1.2.3.4 to any port 22
sudo apt install fail2ban
✅ 最小权限原则
✅ 区分方向
✅ 保留管理通道
✅ 规则持久化
iptables-persistentsudo ufw status verbose
sudo nft list ruleset
sudo iptables -L -n
Debian 防火墙策略 = 通过 iptables / nftables / UFW 等工具,定义“哪些流量可以进出系统”的安全规则。
如果你愿意,我可以:
你当前用的是 Debian 几?服务器还是桌面?