是的,Linux 系统自带强大的防火墙功能,主要通过以下工具实现:
iptables
配置规则。常用命令:
# 查看规则
sudo iptables -L -n -v
# 允许SSH(22端口)
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
# 默认拒绝所有入站流量
sudo iptables -P INPUT DROP
iptables
的更高效防火墙工具,语法更简洁。iptables
、ip6tables
、arptables
等功能。bash
# 创建简单规则(允许HTTP)
sudo nft add rule inet filter input tcp dport 80 accept
iptables/nftables
提供易用的命令行接口(Ubuntu 默认工具)。常用命令:
# 启用UFW
sudo ufw enable
# 允许端口
sudo ufw allow 22/tcp
# 查看状态
sudo ufw status
bash
# 允许HTTP服务
sudo firewall-cmd --add-service=http --permanent
sudo firewall-cmd --reload
# 查看iptables是否运行
sudo iptables -L
# 检查firewalld状态
sudo systemctl status firewalld
# 检查UFW状态
sudo ufw status
iptables/nftables
。UFW
或 firewalld
。UFW
,CentOS 用 firewalld
)。需要进一步帮助(如具体规则配置)可随时补充说明!