-
查询当前配置哪些白名单端口
firewall-cmd --list-port
-
添加白名单端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
-
查询已允许的ip和端口
firewall-cmd --list-rich-rules
-
添加允许IP访问
firewall-cmd --permanent --add-rich-rule="rule family='ipv4' source address='192.168.1.100' accept"
-
添加允许ip访问端口
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="10.110.25.13" port protocol="tcp" port="6379" accept"
-
查询指定端口是否开放
firewall-cmd --query-port=80/tcp
-
删除白名单ip
firewall-cmd --permanent --zone=public --remove-rich-rule="rule family='ipv4' source address='192.168.1.100' accept"
-
删除白名单端口
firewall-cmd --permanent --remove-port=8080/tcp
-
重新载入,配置生效
firewall-cmd --reload
# 启动firewalld服务 sudo systemctl start firewalld
# 使firewalld服务开机自启 sudo systemctl enable firewalld
# 查看当前active zone的防火墙规则 sudo firewall-cmd --list-all