防火墙cmd centos端口转发似乎不起作用?

防火墙cmd centos端口转发似乎不起作用?,centos,firewall,Centos,Firewall,目前,我尝试使用firewall cmd为CentOS设置端口转发 目前我的盒子有两个接口:eth0、eth1 eth0表示内部网络,并且位于区域=公共(默认)中 eth1表示外部网络,位于区域=外部 目前,eth1连接到另一个网络,该网络包含一个到internet的路由器 我的外部防火墙如下所示: external (active) target: default icmp-block-inversion: no interfaces: eth1 sources: 192.16

目前,我尝试使用firewall cmd为CentOS设置端口转发

目前我的盒子有两个接口:eth0、eth1

eth0表示内部网络,并且位于区域=公共(默认)中

eth1表示外部网络,位于区域=外部

目前,eth1连接到另一个网络,该网络包含一个到internet的路由器

我的外部防火墙如下所示:

external (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth1
  sources: 192.168.178.0/24
  services: dhcpv6-client http https ssh
  ports: 1194/udp
  protocols: 
  masquerade: yes
  forward-ports: port=1194:proto=udp:toport=:toaddr=192.168.179.4
  sourceports: 
  icmp-blocks: 
  rich rules: 
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources: 192.168.179.0/24
  services: dhcpv6-client http https ssh
  ports: 7583/tcp
  protocols: 
  masquerade: no
  forward-ports: 
  sourceports: 
  icmp-blocks: 
  rich rules: 
我还有关于端口22的规则:

firewall-cmd --zone=external --add-forward-port=port=22:proto=tcp:toport=22:toaddr=192.168.179.8
但是,这两个规则都不起作用,1194和带有端口22的规则都不起作用。 实际上,我测试了从路由器到机器的端口转发是否有效,这实际上是因为如果我将HAPROXY设置为指向另一台SSH机器:

frontend sshd
    bind 192.168.178.254:22
    mode tcp
    default_backend ssh
    timeout client 1h

backend ssh
    mode tcp
    server static 192.168.179.8:22 check
如果删除
port=22
规则,我就可以连接到它。 我实际上是按照允许的selinux规则运行的

公共区域如下所示:

external (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth1
  sources: 192.168.178.0/24
  services: dhcpv6-client http https ssh
  ports: 1194/udp
  protocols: 
  masquerade: yes
  forward-ports: port=1194:proto=udp:toport=:toaddr=192.168.179.4
  sourceports: 
  icmp-blocks: 
  rich rules: 
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources: 192.168.179.0/24
  services: dhcpv6-client http https ssh
  ports: 7583/tcp
  protocols: 
  masquerade: no
  forward-ports: 
  sourceports: 
  icmp-blocks: 
  rich rules: 
我有什么遗漏吗? 我的意思是,我也试图让它与iptables一起工作,但它根本不起作用

sysctl net.ipv4.ip_forward
返回
net.ipv4.ip_forward=1


Linux机箱不是这两个网络的默认路由器。两个网络都有其他路由器。

看起来两个网络都需要打开伪装:

firewall-cmd --zone=external --permanent --add-masquerade
firewall-cmd --zone=public --permanent --add-masquerade
firewall-cmd --reload

区域目标可以设置为拒绝,这将阻止除区域配置中明确定义的服务和端口之外的所有传入流量

我对内部(您的公共)伪装的问题是,它会破坏路由到服务器的传入外部流量的源IP。这将我的SMTP服务器变成了一个开放中继,因为它信任所有传入的流量,认为源是路由器本身,这是内部的。然而,如果没有伪装,我无法找到内部计算机访问外部区域中具有转发端口的公共静态IP的方法,尽管它可以访问internet本身而不会出现问题,并且传入的外部流量可以到达服务器。如果您将传入的Internet流量转发到inte