linux 防火墙允许ip访问及ip限制转发

允许ip段进行端口访问

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="*.*.*.0/24" port protocol="tcp" port="8080" accept" 

允许ip段进行端口转发

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="*.*.*.0/24" forward-port port="80" protocol="tcp" to-port="8080" "

取消原本的端口转发规则

firewall-cmd --permanent --remove-forward-port=port=80:proto=tcp:toport=8080

取消80端口的开放

firewall-cmd --zone=public --remove-port=80/tcp --permanent

配置装载

firewall-cmd --reload

重启防火墙

systemctl restart firewalld.service

 

查看复杂规则 

firewall-cmd  --list-rich-rules

 

你可能感兴趣的:(linux防火墙配置)