我如何允许从某些主机网络A(在eth0
接口后面)通过我的centos 7框传输到网络B(eth1
后面的一些主机)。
网络A:1.1.1.0/24
网络B:2.2.2.0/24
防火墙接口:
eth1:1.1.1.1
eth2:2.2.2.1
Src主机:1.1.1.30
目的地:2.2.2.45 port 80/tcp and 2.2.2.46 port 80/tcp
转发是启动的,在禁用iptables
的情况下,我可以从1.1.1.30
到达web服务器。
我怎么能用firewall-cmd
实现这一点呢?
发布于 2015-07-23 17:13:52
首先,确保禁用IPTABLES服务,因为FirewallD和IPTABLES服务不能同时共存。
若要禁用IPTABLES,请执行# systemctl stop iptables
接下来,确保启用并启动FirewallD服务;
# systemctl start firewalld && systemctl enable firewalld
现在,您需要将每个可用接口(在本例中为eth0和eth1)分配给特定的网络区域,这些区域在默认情况下可以在firewalld上使用。
假设: eth0属于内部区域(Network),eth1属于公共区域(Network).这样做;
# firewall-cmd --permanent --zone=internal --add-interface=eth0
# firewall-cmd --permanent --zone=public --add-interface=eht1
现在您的防火墙设置已经完成。在配置规则方面,例如,允许来自主机的http流量驻留在网络-A中,您需要在内部区域设置入站规则;
# firewall-cmd --permanent --zone=internal --add-service=http
此外,您还需要在公共区域启用伪装,以便在将IP地址发送到网络-B时转换它们。
# firewall-cmd --permanent --zone=public --add-masquerade
最后,重新加载FirewallD守护进程以实现更改。
# firewall-cmd --reload
列出区域的规则,例如内部区域的规则。
# firewall-cmd --zone=internal --list-all
https://unix.stackexchange.com/questions/217872
复制相似问题