Thursday, August 12, 2010

Postfix internal network information in 'Received' header

With the default Postfix configuration, a "Received" header line is added for every hop, which is fine, but I was surprised to learn a line is also added for mail sent to the local Postfix instance, i.e. 127.0.0.1. It looks something like this:
from mybox.internal.lan (localhost [127.0.0.1])
Assuming this is your last hop before the Internet you are best off just adding your public dns name as the first entry in /etc/hosts (it also gets appended to the Message-ID header value).

However, if you have more internal mail hops you don't want the world knowing about, you will need to create a header_checks rule that removes them (bear in mind this will make diagnosing problems harder...). Put a line like this in /etc/postfix/main.cf:
header_checks = regexp:/etc/postfix/header_checks
And put your regexes in /etc/postfix/header_checks:
/^Received:\sfrom\smybox.internal.lan/ IGNORE

No comments: