30秒上手firewalld防火墙配置

1 安装、启用

# 启动防火墙
systemctl start firewalld

# 加入开机自自动
systemctl enable firewalld
 
# 停止防火墙
systemctl stop firewalld

2 基本查看

# 查看状态 / 端口
firewall-cmd --state
firewall-cmd --list-all

3 禁用 / 放行

# 添加端口(记得reload)
firewall-cmd --zone=public --add-port=8080/tcp --permanent
firewall-cmd --reload
 
# 删除端口(记得reload)
firewall-cmd --zone=public --remove-port=8080/tcp --permanent
firewall-cmd --reload

备注:firewalld与最新版的Docker已兼容,无需docker-ufw的神奇魔法也能用。

Leave a Reply

Your email address will not be published. Required fields are marked *