参考
端口与防火墙
3x-ui 默认使用的端口,以及用于开放这些端口的现成 ufw / nftables 规则。
只开放你实际会用到的端口。下面列出了常用端口,并提供了一个用于生成
ufw 和 nftables 规则的生成器。
常用端口
| Port (default) | Purpose |
|---|---|
22 | SSH(务必保持开放!)。 |
2053 | 面板(可配置)。 |
2096 | 订阅服务器(如果单独部署)。 |
443 | 常用的入站端口(TLS / REALITY)。 |
80 / 443 | 反向代理(如果你运行了反向代理)。 |
实际的入站端口取决于你创建的入站配置。
生成防火墙规则
Firewall rules generator
Pick the ports to open and copy ready-made ufw and nftables rules.
ufw
ufw allow 22/tcp # SSH
ufw allow 2053/tcp # panel
ufw allow 443/tcp # inbound (HTTPS)
ufw enablenftables (/etc/nftables.conf)
#!/usr/sbin/nft -f
flush ruleset
table inet filter {
chain input {
type filter hook input priority 0; policy drop;
iif "lo" accept
ct state established,related accept
icmp type echo-request accept
tcp dport 22 accept # SSH
tcp dport 2053 accept # panel
tcp dport 443 accept # inbound (HTTPS)
}
chain forward {
type filter hook forward priority 0; policy drop;
}
chain output {
type filter hook output priority 0; policy accept;
}
}在启用默认拒绝策略之前,请始终保持 SSH 处于允许状态,并在另一个会话中进行测试,以免把自己锁在外面。

3x-ui