firewall-cmd centos端口转发似乎不起作用?

时间:2017-06-21 08:39:22

标签: centos firewall

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

目前我的盒子有两个界面:eth0,eth1。

eth0代表内部网络,位于zone = public(默认),

eth1代表外部网络,位于zone = external

目前eth1连接到另一个包含到互联网路由器的网络。

我的外部防火墙看起来像这样:

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: 

我也有端口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规则上运行。

公共区域看起来像这样:

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 Box不是两个网络的默认路由器。两者都有其他路由器。

2 个答案:

答案 0 :(得分:0)

看起来两个网络都需要打开假面舞会:

Dispatcher

答案 1 :(得分:0)

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