我有几个RHEL7 / CentOS7服务器,我需要阻止所有的 OUTGOINGstream量到专用机器或专用networking子网,例如CIDR 168.192.10.0/24。
目前我用firewall-cmd尝试过,但并不幸运。 我看到的大多数post都是使用iptables但我宁愿select基于firewalld的解决scheme。
我已经试图将我的解决scheme基于这两个主题阻止传出连接…并阻止与firewalld在Centos 7上的传出连接,但不知何故我的规则必须是错误的,因为我仍然可以打开一个HTTP连接到服务器。
目前的firewalld规则(没有定义规则)
public (active) target: default icmp-block-inversion: no interfaces: eth0 sources: services: dhcpv6-client http https ssh ports: protocols: masquerade: no forward-ports: sourceports: icmp-blocks: rich rules:
假设服务器的服务器源IP是168.192.18.56。 接下来,我试图定义的规则(也与--permanent
firewall-cmd --direct --add-rule ipv4 filter OUTPUT 0 -d 168.192.10.0/24 -j REJECT firewall-cmd --zone=public --add-rich-rule='rule family="ipv4" source address="168.192.18.56" destination address=168.192.10.0/24 reject'
我也试过用DROP动作。 目前的规则是
public (active) target: default icmp-block-inversion: no interfaces: eth0 sources: services: dhcpv6-client http https ssh ports: protocols: masquerade: no forward-ports: sourceports: icmp-blocks: rich rules: rule family="ipv4" destination address="192.168.10.0/24" log prefix="dropped" level="debug" limit value="20/m" drop
现在不知道我是否必须重新加载firewalld ? 在这种情况下,我会把规则永久化。
我现在的误解是 – 假设在192.168.10.30一个Web服务器正在运行。 – 我可以ping如192.168.10.30
– 我也可以打开一个HTTP连接wget 192.168.10.30并得到index.html – 我也可以ping每台机器在被阻止的子网,但也许这需要一个特殊的规则,我想通过阻止所有的stream量ICMP也将被阻止
我会很高兴知道我做错了什么。