====基本信息====
iRedMail版本(检查/ etc / iredmail-release):iRedMail-0.9.5-1
Linux / BSD发行版名称和版本:Ubuntu内部的Ubuntu 14.01容器14.01 TurnkeyLinux核心
存储后端(LDAP / MySQL / PGSQL):MySQL
Web服务器(Apache或Nginx):Apache
Postfix日志摘录:
1月6日10:24:38 iredmail postfix / submission / smtpd [2631]:从x.y.z连接[127.0.0.1]
Jan 6 10:24:38 iredmail postfix / submission / smtpd [2631]:从xyz [127.0.0.1]建立的匿名TLS连接:TLSv1.2与密码ECDHE-RSA-AES128-GCM-SHA256(128/128位)
Jan 6 10:24:38 iredmail postfix / submission / smtpd [2631]:6EEA060306:client = x.y.z [127.0.0.1],sasl_method = LOGIN,sasl_username = address @ x.y.z
Jan 6 10:24:38 iredmail postfix / cleanup [2636]:6EEA060306:message-id =
1月6日10:24:38 iredmail roundcube:用户iaaberga [192.168.121.1];发送至destination@gmail.com的消息; 250:2.0.0好:排队为6EEA060306
Jan 6 10:24:38 iredmail postfix / qmgr [2587]:6EEA060306:from =,size = 575,nrcpt = 1(queue active)
1月6日10:24:38 iredmail postfix / submission / smtpd [2631]:断开与x.y.z的连接[127.0.0.1]
1月6日10:24:38 iredmail postfix / smtpd [2648]:从x.y.z连接[127.0.0.1]
Jan 6 10:24:38 iredmail postfix / smtpd [2648]:C97F262D1B:client = x.y.z [127.0.0.1]
Jan 6 10:24:38 iredmail postfix / cleanup [2636]:C97F262D1B:message-id =
Jan 6 10:24:38 iredmail postfix / qmgr [2587]:C97F262D1B:from =,size = 1628,nrcpt = 1(queue active)
1月6日10:24:38 iredmail postfix / smtpd [2648]:断开与x.y.z的连接[127.0.0.1]
1月6日10:24:38 iredmail amavis [1742] :( 01742-01)通过CLEAN {RelayedInternal},ORIGINATING / MYNETS LOCAL [127.0.0.1]:35413 - > ,队列ID:6EEA060306,消息ID:,mail_id:4QjhhYZODSHf,命中:-2.986,大小:575,queued_as:C97F262D1B,dkim_new = dkim:yz,328 ms,测试:[ALL_TRUSTED = -1,RP_MATCHES_RCVD = -3.199 ,TVD_RCVD_SINGLE = 1.213]
1月6日10:24:38 iredmail postfix / smtp [2642]:6EEA060306:to =,relay = 127.0.0.1 [127.0.0.1]:10026,delay = 0.4,延迟= 0.05 / 0.01 / 0.01 / 0.33, dsn = 2.0.0,status =已发送(MTA为250 2.0.0(smtp:[127.0.0.1]:10025):250 2.0.0 Ok:排队等候为C97F262D1B)
1月6日10:24:38 iredmail postfix / qmgr [2587]:6EEA060306:已删除
1月6日10:24:47 iredmail postfix / smtp [2618]:connect to mx6.mail.icloud.com [17.172.34.71]:25:连接超时
Jan 6 10:24:47 iredmail postfix / smtp [2622]:connect to alt1.gmail-smtp-in.l.google.com [173.194.69.27]:25:连接超时
====
嗨!
我确实在Ubuntu 14.01 / Ubuntu 14.01主机/容器系统上安装了iRedmail作为lxc容器。
虽然我可以收到电子邮件,但Postfix不会发送邮件(似乎是在网络邮件客户端发送的,但绝不会发送到目的地)。
从容器级别连接似乎一般工作:我可以ssh到我有权访问的某些主机;我可以使用apt-get工具来安装新的sw等。
尝试在端口25上telnet alt1.gmail-smtp-in.l.google.com不成功(如果从容器内部完成)。
root@iredmail ~# telnet alt1.gmail-smtp-in.l.google.com 25
Trying 173.194.69.26...
最终连接将失败。
如果我从容器中退出并尝试相同的telnet连接,那么一切都很好
root@lxc ~# telnet alt1.gmail-smtp-in.l.google.com 25
Trying 173.194.69.27...
Connected to alt1.gmail-smtp-in.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP t19si1302495wrb.232 - gsmtp
QUIT
221 2.0.0 closing connection t19si1302495wrb.232 - gsmtp
Connection closed by foreign host.
这是容器的iptables配置:
*mangle
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
COMMIT
*filter
:FORWARD ACCEPT [0:0]
:INPUT DROP [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -i lo -j ACCEPT
-A INPUT -p icmp -m icmp --icmp-type echo-request -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 443 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 12320 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 12321 -j ACCEPT
# Mail SMTP
-A INPUT -p tcp -m tcp --dport 25 -j ACCEPT
-A FORWARD -p tcp -d 192.168.121.1 --dport 25 -j ACCEPT
# POP3
-A INPUT -p tcp -m tcp --dport 110 -j ACCEPT
# SMTPS
-A INPUT -p tcp -m tcp --dport 465 -j ACCEPT
# IMAPS
-A INPUT -p tcp -m tcp --dport 587 -j ACCEPT
# IMAPS - 2
-A INPUT -p tcp -m tcp --dport 993 -j ACCEPT
COMMIT
我不熟悉容器'网络,所以我很可能错过任何明显的东西!
它不看起来是Postfix配置的问题..
感谢您的帮助,
阿尔
答案 0 :(得分:0)
因为它经常发生(一旦你知道解决方案),问题就是微不足道的......
简而言之:主机中的错误NAT设置正在拦截和转发来自所有来源的流量,包含的容器!!
这是HOST' S iptables规则的相关部分,因为它是:
*nat
:PREROUTING ACCEPT [22532:1479233]
:INPUT ACCEPT [22432:1472721]
:OUTPUT ACCEPT [11623:812922]
:POSTROUTING ACCEPT [2959:155572]
-A PREROUTING -p tcp -m tcp --dport 25 -j DNAT --to-destination 192.168.121.174:25
-A PREROUTING -p tcp -m tcp --dport 110 -j DNAT --to-destination 192.168.121.174:110
-A PREROUTING -p tcp -m tcp --dport 143 -j DNAT --to-destination 192.168.121.174:143
-A PREROUTING -p tcp -m tcp --dport 465 -j DNAT --to-destination 192.168.121.174:465
-A PREROUTING -p tcp -m tcp --dport 587 -j DNAT --to-destination 192.168.121.174:587
-A PREROUTING -p tcp -m tcp --dport 993 -j DNAT --to-destination 192.168.121.174:993
-A PREROUTING -p tcp -m tcp --dport 995 -j DNAT --to-destination 192.168.121.174:995
-A POSTROUTING -o br0 -j MASQUERADE
-A POSTROUTING -s 192.168.121.0/24 ! -o natbr0 -j MASQUERADE
COMMIT
它告诉iptables将所有流量说到端口25传递到邮件服务器容器的虚拟地址。 即使是来自容器本身的流量也会发生这种情况。
宾果!!
现在这是正确的设置,其中br0是链接到外部世界的AWS网络接口。 因此,只有首先到达那里的数据包应该路由到电子邮件服务器包的NATted虚拟地址。
*nat
:PREROUTING ACCEPT [22532:1479233]
:INPUT ACCEPT [22432:1472721]
:OUTPUT ACCEPT [11623:812922]
:POSTROUTING ACCEPT [2959:155572]
-A PREROUTING -p tcp -m tcp --in-interface br0 --dport 25 -j DNAT --to-destination 192.168.121.174:25
-A PREROUTING -p tcp -m tcp --in-interface br0 --dport 110 -j DNAT --to-destination 192.168.121.174:110
-A PREROUTING -p tcp -m tcp --in-interface br0 --dport 143 -j DNAT --to-destination 192.168.121.174:143
-A PREROUTING -p tcp -m tcp --in-interface br0 --dport 465 -j DNAT --to-destination 192.168.121.174:465
-A PREROUTING -p tcp -m tcp --in-interface br0 --dport 587 -j DNAT --to-destination 192.168.121.174:587
-A PREROUTING -p tcp -m tcp --in-interface br0 --dport 993 -j DNAT --to-destination 192.168.121.174:993
-A PREROUTING -p tcp -m tcp --in-interface br0 --dport 995 -j DNAT --to-destination 192.168.121.174:995
-A POSTROUTING -o br0 -j MASQUERADE
-A POSTROUTING -s 192.168.121.0/24 ! -o natbr0 -j MASQUERADE
COMMIT
显然,如果没有拦截循环,容器内的电子邮件服务器就可以轻松发送邮件!!