解决 Zeek 报错 Notice email failed to send: connection refused 告警邮件发送失败修复
排查 Zeek 触发安全事件后邮件通知丢失,系统日志显示 sendmail: connect to 127.0.0.1[25]: Connection refused,分析 Postfix 本地邮件代理配置。
问题现象
Zeek 检测到严重网络攻击时触发 notice 动作,但在终端或日志中输出邮件派送错误:
postdrop: warning: unable to look up public/pickup: No such file or directory
sendmail: fatal: connect to 127.0.0.1[25]: Connection refused
触发根因
- 宿主机未安装或未启动本地 SMTP 邮件代理(MTA,如 Postfix 或 Exim),Zeek 默认调用的
sendmail命令无法建立 25 端口连接; - 云服务器厂商(如 AWS、阿里云)在安全组和 VPC 层面默认封禁了出站 25 端口。
解决步骤
若需本地派送,启动 Postfix 本地服务
安装并启动邮件服务:
sudo apt-get install postfix -y
sudo systemctl enable --now postfix
若需对接外部 SMTP(如企业邮箱),配置 Zeek 调用外部脚本
在 share/zeek/site/local.zeek 中重定义邮件处理逻辑或使用 msmtp 替代传统 sendmail:
sudo apt-get install msmtp msmtp-mta -y
配置 /etc/msmtprc 指定外部 465/587 SSL 邮箱认证,Zeek 将无缝调用其派发告警。
验证确认
触发一次测试 Notice 验证邮件派送:
管理员邮箱成功收到格式完备的威胁详情告警通知。


