大网数据广告活动
服务器运维问答

Can postfix log source ports for inbound SMTP connections?

· 52CE 我爱测

At the moment, postfix logs inbound connections like this: May 4 11:15:01 hostname postfix/smtpd[161025]: connect from unknown[192.0.2.1] This isn't enough information for hosting providers to respond to abuse reports where they …

问题原文

原帖链接 · Flup · CC BY-SA 4.0

At the moment, postfix logs inbound connections like this:

May  4 11:15:01 hostname postfix/smtpd[161025]: connect from unknown[192.0.2.1]

This isn't enough information for hosting providers to respond to abuse reports where they use CGNAT. They need the source port to identify the offending customer.

Is there any way to make postfix log the source port? Something like this would be ideal:

May  4 11:15:01 hostname postfix/smtpd[161025]: connect from unknown[192.0.2.1:12345]

已采纳解答

原帖链接 · anx · CC BY-SA 4.0

Yes, just set smtpd_client_port_logging to yes.

smtpd_client_port_logging (default: no)

Enable logging of the remote SMTP client port in addition to the hostname and IP address. The logging format is "host[address]:port".

This feature is available in Postfix 2.5 and later.

-- man 5 postconf

Note that the format does not quite match your example, it will place the port after the brackets: unknown[192.0.2.1]:12345

Beware of log aggregation and analysis tools that might need their regex patterns adjusted to correctly parse the changed format - notably utilities like fail2ban might no longer detect the relevant log lines.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2022-05-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。