温馨提示×

debian防火墙怎么开启服务

小樊
41
2026-10-05 07:32:04
栏目: 智能运维

在 Debian 里“开启防火墙服务”通常指 启用并启动防火墙软件,最常见的有两种:


一、使用 ufw(推荐,简单)

1. 安装(一般已自带)

sudo apt update
sudo apt install ufw

2. 启用服务(开机自启 + 立即启动)

sudo ufw enable

3. 查看状态

sudo ufw status

4. 常用示例

sudo ufw allow 22/tcp      # 允许 SSH
sudo ufw allow 80/tcp      # 允许 HTTP
sudo ufw allow 443/tcp     # 允许 HTTPS

二、使用 nftables(Debian 新默认)

1. 安装

sudo apt install nftables

2. 启动并设置开机自启

sudo systemctl enable nftables
sudo systemctl start nftables

3. 查看状态

sudo systemctl status nftables
sudo nft list ruleset

三、使用 iptables(传统方式,不推荐新系统)

sudo apt install iptables
sudo systemctl enable iptables
sudo systemctl start iptables

四、如果你说的“开启某个服务被防火墙放行”

例如放行 SSH:

sudo ufw allow ssh

或

sudo ufw allow 22

如果你能说明:

  • 用的是 Debian 几
  • 用的是 云服务器还是物理机
  • 想开的是 SSH / Web / 数据库

我可以给你更精确的命令。

0 踩