正在加载...
118 字
1 分钟
Nftables防火墙配置
2026-06-24

Nftables防火墙配置#

Terminal window
sudo apt update && sudo apt install -y nftables

写配置

sudo tee /etc/nftables.conf > /dev/null <<'EOF'
#!/usr/sbin/nft -f
flush ruleset
table ip filter {
chain input {
type filter hook input priority filter; policy drop;
iifname "lo" accept
ct state established,related accept
ct state invalid drop
icmp type {
destination-unreachable,
time-exceeded,
parameter-problem
} accept
tcp dport 48256 ct state new accept
counter drop
}
chain forward {
type filter hook forward priority filter; policy drop;
}
chain output {
type filter hook output priority filter; policy accept;
}
}
EOF

检查并加载

Terminal window
sudo nft -c -f /etc/nftables.conf && sudo nft -f /etc/nftables.conf
sudo systemctl enable --now nftables
Nftables防火墙配置
https://blog.vian.im/nftables防火墙配置/
作者
woioeow
发布于
2026-06-24
许可协议
CC BY-NC-SA 4.0