firewall-cmd小记

//为指定ip添加端口的访问权限
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="127.0.0.1" port protocol="tcp" port="8080" accept"
firewall-cmd --reload
firewall-cmd --list-all

//为指定ip删除端口的访问权限
firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="127.0.0.1" port protocol="tcp" port="8080" accept"
firewall-cmd --reload
firewall-cmd --list-all

//开放某个端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
//开放多个端口
firewall-cmd --zone=public --add-port=80-85/tcp --permanent

firewall-cmd --reload
//查看 返回 yes 代表开启成功
firewall-cmd --zone=public --query-port=8913/tcp

//关闭端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent
firewall-cmd --reload

查看版本: 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

详情可参照:https://wangchujiang.com/linux-command/c/firewall-cmd.html

你可能感兴趣的:(Linux)