# 针对某个 IP开放 firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" accept"
# 删除某个IP firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="192.168.142.166" accept"
# 针对一个ip段访问 firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.0.0/16" accept" firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.1.0/24" port protocol="tcp" port="9200" accept"
# 添加多个端口 firewall-cmd --permanent --zone=public --add-port=8080-8083/tcp # 删除某个端口 firewall-cmd --permanent --zone=public --remove-port=81/tcp
端口转发
添加(例如3306 -> 3336):
firewall-cmd --permanent --zone=public --add-forward-port=port=3336:proto=tcp:toport=3306:toaddr=
删除:
firewall-cmd --permanent --remove-forward-port=port=3306:proto=tcp:toport=3336:toaddr=
查看转发的端口:firewall-cmd --list-forward-ports
# 添加操作后别忘了执行重载 firewall-cmd --reload