我有一个运行时间非常短的Postfix服务器,它工作,但我不得不今天重新启动服务器,我不再接收来自外部来源的电子邮件:
Jan 23 01:34:44 myservername postfix/smtpd[1055]: connect from db3ehsobe006.messaging.microsoft.com[213.199.154.144] Jan 23 01:34:45 myservername postfix/smtpd[1055]: warning: connect to 127.0.0.1:10023: Connection refused Jan 23 01:34:45 myservername postfix/smtpd[1055]: warning: problem talking to server 127.0.0.1:10023: Connection refused Jan 23 01:34:46 myservername postfix/smtpd[1055]: warning: connect to 127.0.0.1:10023: Connection refused Jan 23 01:34:46 myservername postfix/smtpd[1055]: warning: problem talking to server 127.0.0.1:10023: Connection refused Jan 23 01:34:46 myservername postfix/smtpd[1055]: NOQUEUE: reject: RCPT from db3ehsobe006.messaging.microsoft.com[213.199.154.144]: 451 4.3.5 Server configuration problem; from=<MyKnownWorking@EmailAccountOutside> to=<[email protected]> proto=ESMTP helo=<db3outboundpool.messaging.microsoft.com>
服务器正在侦听port 10023 ,但我注意到它只能通过IPv6侦听:
> sudo netstat -a | grep 10023 tcp6 0 0 ip6-localhost:10023 [::]:* LISTEN
我没有任何防火墙规则,否认具体的端口,地狱,我去冲刷规则集,以确认它。 这是我postconf-n的输出(我编辑了我的域名代替“mydomain.com”:
> sudo postconf -n alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases append_dot_mydomain = no biff = no broken_sasl_auth_clients = yes config_directory = /etc/postfix content_filter = amavis:[127.0.0.1]:10024 disable_vrfy_command = yes inet_interfaces = all inet_protocols = ipv4 mailbox_size_limit = 0 message_size_limit = 0 mydestination = localhost.$mydomain, localhost, mail.mydomain.com, servername.mydomain.com mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mynetworks_style = host myorigin = /etc/mailname readme_directory = no receive_override_options = no_address_mappings recipient_delimiter = + relayhost = smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache smtp_use_tls = yes smtpd_banner = mail.mydomain.com ESMTP $mail_name smtpd_delay_reject = yes smtpd_helo_required = yes smtpd_recipient_restrictions = reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_non_fqdn_recipient, reject_unknown_recipient_domain, reject_unauth_destination, check_policy_service inet:127.0.0.1:10023, permit smtpd_sasl_auth_enable = yes smtpd_sasl_local_domain = smtpd_sasl_security_options = noanonymous smtpd_sender_restrictions = permit_sasl_authenticated, permit_mynetworks, warn_if_reject reject_non_fqdn_sender, reject_unknown_sender_domain, reject_unauth_pipelining, permit smtpd_tls_cert_file = /etc/ssl/private/mail.mydomain.com.crt smtpd_tls_key_file = /etc/ssl/private/mail.mydomain.com.key smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtpd_use_tls = yes virtual_alias_maps = mysql:/etc/postfix/maps/alias.cf virtual_gid_maps = static:5000 virtual_mailbox_base = /var/spool/mail/virtual virtual_mailbox_domains = mysql:/etc/postfix/maps/domain.cf virtual_mailbox_limit = 0 virtual_mailbox_maps = mysql:/etc/postfix/maps/user.cf virtual_uid_maps = static:5000
正如你所看到的,我甚至试图通过inet_protocols来指定它监听ipv4连接。 我试过,没有这个命令。
任何帮助排除故障将不胜感激! 当然,如果你看到我的configuration上的任何东西都显得很愚蠢,那么我的意见不是很高。
您上次对smtpd_recipient_restrictions的检查使用策略服务来validation收件人。 通常这是一个postgrey服务,并且似乎在Postfix连接上有一些问题。
smtpd_recipient_restrictions = ...,check_policy_service inet:127.0.0.1:10023, permit
如果您从smtpd_recipient_restrictions中删除了check_policy_service inet:127.0.0.1:10023 ,则应该消除该错误,但是您仍然应该确定将在此处运行的postgrey或其他服务发生了什么。
在Ubuntu系统上检查Postgrey
通常情况下,postgrey的默认configuration将侦听端口10023的连接,并确定它们是否应该被允许或拒绝。 Unbutu服务器上的一些部分,您可以检查,看看是否安装了…
/etc/default/postgrey文件吗? 这是基本的configuration文件。 /etc/postgrey文件夹吗? 这是您可以将元素列入白名单的地方。 > which postgrey它find一个二进制? 我的是在/usr/sbin/postgrey 。 /etc/init.d/postgrey脚本吗? 这是Ubuntu守护进程的典型位置。 这些只会给你一些线索,如果这个服务器可能有一次postgreyconfiguration。 如果进程在服务器上运行不正确,您将需要进一步查看故障排除。
面对同样的问题,尝试了许多方法,如bshea ,google提出和尝试。
基地: Ubuntu 14.04.2 LTS, postgrey服务启动,但没有出现在进程列表,即服务启动,但悄悄退出。
find更改/etc/default/postgrey行的解决scheme:
改变这一行:
POSTGREY_OPTS="--inet=10023"
对此
POSTGREY_OPTS="--inet=127.0.0.1:10023"
无需玩端口,协议,也不需要版本降级。 不能解释为什么,但服务是在ps -aux和所有的作品。
其实,你不是被迫使用ipv6,你可以将Postgrey和Postfix设置为ipv4。 问题是,Postgrey(可能版本1.33和更新)拒绝启动ipv4本地主机IP 127.0.0.1,所以你可以使用你的ethX IP地址。
在/etc/postfix/main.cf中改变这个:
check_policy_service inet:127.0.0.1:10023
至:
check_policy_service inet:<your_ipv4_address>:10023
然后重新启动Postfix:
sudo service postfix restart
在/ etc / default / postgrey中改变这个:
POSTGREY_OPTS="--inet=10023 --delay=60"
至:
POSTGREY_OPTS="--inet=<your_ipv4_address>:10023 --delay=60"
然后重新启动Postgrey:
sudo service postgrey restart
非常有用的是这个Debian邮件列表消息:
戴维斯 – 你是对的,postgrey在12.04LTS中改为使用IPv6。 升级不会改变它的后缀,并没有提醒你做出改变。
所以你必须自己做。 改变这个:
check_policy_service inet:127.0.0.1:10023
至:
check_policy_service inet:::1:10023
在/etc/postfix/master.cf文件中,然后重新启动postfix:
sudo service postfix restart
它将允许postfix与IPv6通信。
IP:PORT问题对我来说不是/不是问题(Ubuntu 14.04.2 LTS)。 假设postgrey在本地端口连接/执行失败时断开/退出可能会引起误解。
首先检查守护进程是否被识别为正在运行:
sudo service postgrey status
如果没有运行/识别, 您仍然会看到 :
warning: problem talking to server [::1]:10023: Connection refused
在你的邮件日志中。 Postgrey只是不附加/运行。 如果你发现它正在运行(可能不止一次),并且无法停止服务或状态,那么你可能有一个pid / truncate问题。 如果是这样,那么:
ps a | grep postgrey
手动杀死(每个)进程。 从/ var / run(/ run)中删除任何postgrey.pid文件。
假设所有的postgrey文件都是默认的,并且正在尝试启动,但是在重新启动/重新启动/停止时失败(在检查'sudo service postgrey status'之后),你可能会遇到lockfile和stop-start-daemon命名进程的问题。
POSTGREY有一个非常基本的init.d脚本,它在执行任何事情之前/之后都没有做太多的检查。 维护人员确实需要在这方面工作。
主要的问题是寻找被截断的命名文件的启动 – 停止 – 守护进程 :
( https://bugs.launchpad.net/ubuntu/+source/postgrey/+bug/1289424 )
安装的脚本检查$ NAME =“postgrey”。
(“–name $ NAME”)
不幸的是,它需要使用的是(Ubuntu / Debian):'/ usr / sbin / postg'
(只有15个字符,是path的一部分 – 这显然不存在)
修复(添加包含path的截断版本的variablesPROCNAME):
PROCNAME=`echo $DAEMON | cut -c -15`
(然后会检查'/ usr / sbin / postg')
并将在“–name”下进行:
stop) log_daemon_msg "Stopping $DESC" "$NAME" if start-stop-daemon --stop --oknodo --quiet \ --pidfile $PIDFILE --name $PROCNAME
..
reload|force-reload) log_action_begin_msg "Reloading $DESC configuration..." if start-stop-daemon --stop --signal 1 --quiet \ --pidfile $PIDFILE --name $PROCNAME
(可选的)
当我在它的时候,我把锁文件放在它自己的目录里:'/run/postgrey/postgrey.pid'。
如果你喜欢它在自己的目录中,你需要添加这个位来每次重新创build文件夹:
PIDFOLDER=/var/run/$NAME PIDFILE=$PIDFOLDER/$NAME.pid
检查现有的目录/文件夹:
check_pid_dir() { if [ ! -d $PIDFOLDER ]; then mkdir $PIDFOLDER chmod 0755 $PIDFOLDER fi }
并添加function到“开始”:
case "$1" in start) check_pid_dir log_daemon_msg "Starting $DESC" "$NAME"
我的完整的init.d脚本在这里: https : //gist.github.com/bmatthewshea/50e2038563b103e466ea
我还没有testing过这么多,但是到目前为止它肯定比默认的更好。 🙂