FirewallD 强制环回 Centos 7 端口 25 电子邮件

FirewallD 强制环回 Centos 7 端口 25 电子邮件

所以我知道这是某种防火墙规则问题。我会尽力解释。我有一个 VPS 内部的 KVM VM 环境。

网络图

VPS-WAN=1.1.1.1 => KVM-virbr 接口=10.0.0.1 => KVM-VM 10.0.0.2

由于这些规则,我可以从任何地方通过 telnet 连接到互联网来访问 KVM-VM。

firewall-cmd --zone=public --add-forward-port=port=25:proto=tcp:toport=25:toaddr=10.0.0.2 --permanent

从 KVM-VM 发送电子邮件时出现问题。如果我从该主机的 25 端口进行 telnet 操作,我会被重定向回我自己。

查看 tcpdump,我可以看到数据包只是被重定向到自身。例如,我正在 telnet 8.8.8.8 25,因为那里显然没有 smtp 服务,我的 telnet 会话被重定向回我自己。

5:08:36.439608 IP 10.10.0.2.44558 > 10.10.0.2.25: Flags [S], seq 688613034, win 29200, options [mss 1460,sackOK,TS val 1183513828 ecr 0,nop,wscale 7], length 0
05:08:36.439668 IP 10.10.0.1.44558 > 10.10.0.2.25: Flags [S], seq 688613034, win 29200, options [mss 1460,sackOK,TS val 1183513828 ecr 0,nop,wscale 7], length 0
05:08:36.439901 IP 10.10.0.2.25 > 10.10.0.2.44558: Flags [S.], seq 1310863117, ack 688613035, win 28960, options [mss 1460,sackOK,TS val 1183513829 ecr 1183513828,nop,wscale 7], length 0
05:08:36.439927 IP 8.8.8.8.25 > 10.10.0.2.44558: Flags [S.], seq 1310863117, ack 688613035, win 28960, options [mss 1460,sackOK,TS val 1183513829 ecr 1183513828,nop,wscale 7], length 0
05:08:36.440127 IP 10.10.0.2.44558 > 10.10.0.2.25: Flags [.], ack 1, win 229, options [nop,nop,TS val 1183513829 ecr 1183513829], length 0
05:08:36.440152 IP 10.10.0.1.44558 > 10.10.0.2.25: Flags [.], ack 1310863118, win 229, options [nop,nop,TS val 1183513829 ecr 1183513829], length 0
05:08:36.483292 IP 10.10.0.2.25 > 10.10.0.2.44558: Flags [P.], seq 1:35, ack 1, win 227, options [nop,nop,TS val 1183513872 ecr 1183513829], length 34: SMTP: 220 mail.axoai.com ESMTP Postfix
05:08:36.483346 IP 8.8.8.8.25 > 10.10.0.2.44558: Flags [P.], seq 1:35, ack 1, win 227, options [nop,nop,TS val 1183513872 ecr 1183513829], length 34: SMTP: 220 mail.axoai.com ESMTP Postfix
05:08:36.483558 IP 10.10.0.2.44558 > 10.10.0.2.25: Flags [.], ack 35, win 229, options [nop,nop,TS val 1183513872 ecr 1183513872], length 0
05:08:36.483582 IP 10.10.0.1.44558 > 10.10.0.2.25: Flags [.], ack 35, win 229, options [nop,nop,TS val 1183513872 ecr 1183513872], length 0

答案1

我必须像这样从 WAN IP 地址添加目标规则并删除旧规则。

此规则仅允许来自父主机的 wan 的数据包发往子主机。

sudo firewall-cmd --zone=public --permanent  --add-rich-rule 'rule family=ipv4 destination address=1.1.1.1  forward-port port=25 protocol=tcp to-port=25 to-addr=10.0.0.2'

编辑我还必须添加化装舞会

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

相关内容