Postfix 不允许端口 25 的外部连接
Posted
技术标签:
【中文标题】Postfix 不允许端口 25 的外部连接【英文标题】:Postfix won't allow external connections for port 25 【发布时间】:2018-01-24 15:47:33 【问题描述】:我已经安装了 postfix,但有一段时间遇到了问题。
我能够连接到本地主机上的端口 25,但是当我从外部计算机远程登录端口 25 时,连接似乎已建立,但随后挂断。
我得到了回应:
421 无法连接到 SMTP 服务器 xx.xxx.xx.xxx (xx.xx.xx.xxx:25), 连接错误 10061 连接被外部主机关闭。
我将 inet_interfaces 设置为 all。
main.cf
soft_bounce = no
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = mydomain.com
mydomain = mydomain.com
myorigin = $myhostname
inet_interfaces = all
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
mynetworks = 168.100.189.0/28, 127.0.0.0/8
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
home_mailbox = Maildir/
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix-2.10.1/samples
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
smtpd_sasl_auth_enable = yes
broken_sasl_auth_clients = yes
smtpd_sasl_type = dovecot
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
master.cf
smtp inet n - n - - smtpd
submission inet n - n - - smtpd
-o syslog_name=postfix/submission
smtps inet n - n - - smtpd
pickup unix n - n 60 1 pickup
cleanup unix n - n - 0 cleanup
qmgr unix n - n 300 1 qmgr
tlsmgr unix - - n 1000? 1 tlsmgr
rewrite unix - - n - - trivial-rewrite
bounce unix - - n - 0 bounce
defer unix - - n - 0 bounce
trace unix - - n - 0 bounce
verify unix - - n - 1 verify
flush unix n - n 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - n - - smtp
relay unix - - n - - smtp
showq unix n - n - - showq
error unix - - n - - error
retry unix - - n - - error
discard unix - - n - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - n - - lmtp
anvil unix - - n - 1 anvil
scache unix - - n - 1 scache
netstat -plnt | grep 25
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 10742/master
tcp6 0 0 :::25 :::* LISTEN 10742/master
【问题讨论】:
这个问题属于Server Fault,因为它与基础设施有关,而不是编程本身。 【参考方案1】:到 smtp 端口的传入连接可能被防火墙阻止。
您可以尝试使用tcptraceoute
等工具来定位此类防火墙。
【讨论】:
我得到了结果: traceroute to mydomain.com (xx.xxx.xx.xxx), 30 hops max, 60 byte packet 1 gateway (xx.xxx) 1.784 ms 0.969 ms 1.519 ms 2 xx.xxx.xx.xxx (xx.xxx.xx.xxx)以上是关于Postfix 不允许端口 25 的外部连接的主要内容,如果未能解决你的问题,请参考以下文章
如何在Ubuntu 16.04上安装并配置Postfix作为只发送SMTP服务器