微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

centos – 尝试设置邮件服务器,无法使端口(25,587)正常工作

我到处搜索,我真的在努力解决这个问题.我想我已经尝试了一切.

背景信息

>使用CentOS 6.7的VPS
> Postfix 2.6.6
> dovecot,amavis,mysql,fail2ban
>我已经与我的VPS提供商验证他们没有阻止任何端口.

我做过的事情

>删除了股票sendmail
>我已经安装了postfix,dovecot,MysqL等完整的邮件解决方
>我只允许使用STARTTLS的imap,smtp(端口143和587)
>仅使用密钥禁用SSH登录
>我可以收到邮件(通过端口143)
>我可以从localhost telnet到两个端口(587,25),我得到后缀问候语
>尝试连接到587或25(邮件客户端或telnet)得到零响应,即连接超时

我尝试过的事情

1)港口是否开放?是的,iptables:

Chain INPUT (policy DROP 11 packets,1375 bytes)
 pkts bytes target     prot opt in     out     source               destination
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:587
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:587
   25  2579 f2b-dovecot  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           multiport dports 110,995,143,993,587,465,4190
   68  7788 f2b-postfix  tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           multiport dports 25,587
    0     0 f2b-sshd   tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           multiport dports 22
   25  2579 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:143
    7   600 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:8080
23464 2662K ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
   49  2940 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0
    0     0 ACCEPT     icmp --  *      *       0.0.0.0/0            0.0.0.0/0           icmp type 8
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:3915
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:80
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:443
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:143
    0     0 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:587
    5   300 ACCEPT     tcp  --  *      *       0.0.0.0/0            0.0.0.0/0           tcp dpt:25

Chain FORWARD (policy DROP 0 packets,0 bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain OUTPUT (policy ACCEPT 23235 packets,2494K bytes)
 pkts bytes target     prot opt in     out     source               destination

Chain f2b-dovecot (1 references)
 pkts bytes target     prot opt in     out     source               destination
   25  2579 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0

Chain f2b-postfix (1 references)
 pkts bytes target     prot opt in     out     source               destination
   68  7788 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0

Chain f2b-sshd (1 references)
 pkts bytes target     prot opt in     out     source               destination
    0     0 RETURN     all  --  *      *       0.0.0.0/0            0.0.0.0/0

2)后缀是否在端口587上侦听?是.它只在localhost上侦听吗?不,任何主持人.

这是netstat:

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:25                  0.0.0.0:*                   LISTEN      7173/master
tcp        0      0 0.0.0.0:443                 0.0.0.0:*                   LISTEN      917/httpd
tcp        0      0 127.0.0.1:4190              0.0.0.0:*                   LISTEN      749/dovecot
tcp        0      0 0.0.0.0:587                 0.0.0.0:*                   LISTEN      7173/master
tcp        0      0 0.0.0.0:143                 0.0.0.0:*                   LISTEN      749/dovecot
tcp        0      0 127.0.0.1:24                0.0.0.0:*                   LISTEN      749/dovecot

这里也是postfix / main.cf,以防万一:

# Enable both IPv4 and/or IPv6: ipv4,ipv6,all.
inet_protocols = ipv4

# Enable all network interfaces.
inet_interfaces = all

3)您是否正确强制安全连接?据我所知,是的,这是postfix / master.cf:

# Submission,port 587,force TLS connection.
submission inet n       -       n       -       -       smtpd
  -o syslog_name=postfix/submission
  -o smtpd_tls_security_level=encrypt
  -o smtpd_sasl_auth_enable=yes
  -o smtpd_client_restrictions=permit_mynetworks,permit_sasl_authenticated,reject
  -o content_filter=smtp-amavis:[127.0.0.1]:10026

4)smtpd限制怎么样?好像可以:

# HELO restriction
smtpd_helo_required = yes
smtpd_helo_restrictions =
    permit_mynetworks
    permit_sasl_authenticated
    reject_non_fqdn_helo_hostname
    reject_invalid_helo_hostname
    check_helo_access pcre:/etc/postfix/helo_access.pcre

5)后缀是否正常工作?

是的,登录服务器并从控制台工程发送测试邮件,另一端收到电子邮件,即:

echo "Test mail from postfix" | mail -s "Test Postfix" user@something.com

6)在端口587上连接时会发生什么?

显然,什么都没有.如果我尝试telnet到任何随机端口,我至少得到一些东西.例如,尝试telnet到端口666(未打开)不会产生对客户端的回复,但至少我在tcpdump中得到了一些东西:

15:22:20.305697 IP xxx > xxx.com.mdqs: Flags [S],seq 3195304468,win 8192,options [mss 1352,nop,wscale 8,sackOK],length 0

当tcpdumping端口587时,尝试telnet到它时绝对没有任何反应.

我还缺少什么?

上面的一切都耗尽了我对仍然可以尝试的事物的了解.我已经设法将它钉在我的587端口被完全阻挡了.正如我所说,我的VPS提供商确认他们根本没有阻止任何端口.我尝试过25端口,这是同一个故事.

我能看到的唯一另一件事是我在设置我的服务器时以某种方式阻止了这些端口,但我不记得是否是这种情况而且我不知道如何测试它.

我真的很感激你能给我的任何帮助.事实上,我买了一杯啤酒,无论谁帮助我解决这个问题,我已经浪费了两天时间,而且开始变得非常讨厌.

Reachergilt,欢迎来到SF,并感谢您提出优秀的第一个问题.你可能觉得我们已经拯救了你,但老实说 – 你已经完成了所有繁重的任务,并且非常系统地展示了它.有了这样的法医心态,我希望你能在这些部分保持一段时间.

tcpdump输出特别诅咒.它无可置疑地证明你的连接尝试甚至没有到达你的服务器,这可以免除服务器的防火墙,postfix的绑定以及服务器端的所有其他内容.

有了这个指针,你已经离开并确认你的出站连接被阻止了,所以你的测试从来没有达到你的服务器.由于垃圾邮件发送僵尸网络使用它们,因此从现代网络中阻止出站25(并且在较小程度上,587)是相当(令人沮丧)正常的.

无论如何,您现在很高兴您的新邮件服务器正如宣传的那样工作,这很好.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。