防火墙永久开启一个端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
防火墙关闭一个端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent
防火墙批量添加开放的端口
firewall-cmd --zone=public --add-port=4400-4600/udp --permanent
防火墙指定某个端口对某个固定ip开放
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="5432" accept"
防火墙指定某个端口对某个固定ip段开放
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.2.0/24" port protocol="tcp" port="5432" accept"
防火墙删除某个端口对某个固定ip的规则
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="11300" accept"
启动防火墙:
systemctl start firewalld
关闭防火墙:
systemctl stop firewalld
查看防火墙状态:
systemctl status firewalld
防火墙开机禁用 :
systemctl disable firewalld
防火墙开机启用 :
systemctl enable firewalld
查看版本:
firewall-cmd --version
查看帮助:
firewall-cmd --help
显示状态:
firewall-cmd --state
查看所有打开的端口:
firewall-cmd --zone=public --list-ports
更新防火墙规则:
firewall-cmd --reload
查看区域信息:
firewall-cmd --get-active-zones
查看指定接口所属区域:
firewall-cmd --get-zone-of-interface=eth0
拒绝所有包: firewall-cmd --panic-on
取消拒绝状态:
firewall-cmd --panic-off
查看是否拒绝:
firewall-cmd --query-panic