Zimbra Reverse DNS Lookup: 4 Easy Steps, Avoid Mistakes
A reverse DNS lookup check makes your Zimbra server refuse mail from clients whose IP address has no proper PTR record. It is a cheap way to cut spam from hijacked home machines, but done the wrong way it also blocks real mail or gets wiped at the next Zimbra upgrade. The first version of this article edited main.cf by hand and mixed two different Postfix restrictions; this rewrite checks every setting against the Postfix manual and the Zimbra Administrator Guide.
How this article was written: there is no Zimbra server in the author's lab, so nothing here is a fresh test run and no command output is shown. The restriction names and their meaning come from the Postfix postconf(5) manual; the Zimbra-specific behaviour comes from the Zimbra Administrator Guide. Both were read on 2026-11-01.
Contents
What a reverse DNS lookup check really tests
A PTR record maps an IP address back to a host name, and a reverse DNS lookup asks for it. When a remote server connects to your port 25, Postfix can look at that address and decide whether the name behind it is trustworthy. There are two restrictions with a similar name, and the old post used both without saying that they are different:
reject_unknown_reverse_client_hostname: reject the request when the client IP address has no address-to-name mapping. The manual calls this a weaker restriction.reject_unknown_client_hostname: reject when the address-to-name mapping fails, or the name-to-address mapping fails, or the name-to-address mapping does not match the client IP address. The manual calls it a stronger restriction that triggers on three conditions instead of one.
Both kinds of DNS lookup failure reply with code 450 by default (the parameter unknown_client_reject_code), and the manual adds that the reply is always 450 when the lookup failed because of a temporary error. A 450 is a temporary rejection, so a legitimate sender whose DNS is broken for a moment will retry instead of bouncing the message. That is also why a failure of your own resolver causes deferred mail, not lost mail.
Why you should not edit main.cf for a reverse DNS lookup rule
The original steps opened /opt/zimbra/postfix/conf/main.cf and added a line for smtpd_client_restrictions. The Administrator Guide explains why this is a bad idea: Zimbra modified main.cf to include the LDAP tables, and the configuration daemon pulls data from Zimbra LDAP and rewrites the Postfix files. The guide adds a clear warning: "changes made to postfix configuration files will be overwritten with every upgrade", and if possible you should use Zimbra defined parameters instead.
There is a second problem with the old line. In Postfix, a parameter assignment replaces the whole value. Writing smtpd_client_restrictions = reject_unknown_reverse_client_hostname would throw away any other client restrictions already set in that parameter. The old post then ran a second command with the other restriction name, so the two steps did not even agree.
Enable the reverse DNS lookup restriction the Zimbra way
For this DNS lookup, Zimbra's own parameter for extra SMTP restrictions is zimbraMtaRestriction. The guide shows how to view it and how to add values: first look at what is set, then add yours with a plus sign so the existing values stay. Run these as the zimbra user:
zmprov gacf zimbraMtaRestriction
zmprov mcf +zimbraMtaRestriction "reject_unknown_client_hostname"
The second line is the command from the original post, with the stronger restriction. The guide uses the same form for other values, for example zmprov mcf +zimbraMtaRestriction "check_policy_service unix:private/policy", and a minus sign removes a value. Choose the weaker reject_unknown_reverse_client_hostname instead if you only want to require that a PTR record exists; check that your Zimbra version accepts it by running the first command again afterwards and reading the list.
Do not edit anything else. According to the guide, the configuration daemon polls the LDAP directory every two minutes and updates the Postfix files, so the new value reaches Postfix by itself. If you want it immediately, restart the MTA with zmmtactl restart. Then confirm the result in the live Postfix configuration with postconf smtpd_client_restrictions and look for your restriction in the list.
Check your own PTR record and test the rule
Before you turn the DNS lookup rule on, make sure your server passes it, because other servers will apply the same check to you. Use dig -x <your IP address> and confirm that the name it returns resolves back to the same IP address with a normal lookup. With the stronger restriction that forward-confirmed match is exactly what is tested. Your hosting provider normally controls the PTR record for a public IP, so ask them to set it to your mail host name.
After the change, test the DNS lookup rule with a message from a server that has no PTR record, and watch the mail log. A rejected connection shows the 450 reply described above. Keep an eye on the log for a few days: if a partner's server is refused, you can see it and decide whether to exempt it.
Common mistakes with a reverse DNS lookup rule
- Editing
main.cfby hand, which Zimbra overwrites with every upgrade. - Replacing the whole
smtpd_client_restrictionsvalue instead of adding to it. - Mixing the weaker and the stronger restriction name in different steps.
- Applying the rule without knowing that Postfix evaluates restrictions in order and the first match wins, so allow rules for trusted clients must come first. The manual describes
permit_sasl_authenticatedas permitting clients that authenticated with SMTP AUTH. - Forgetting that your own server needs a correct PTR record, so that the other side's DNS lookup of your address succeeds.
If a client is blocked after the change, the log line helps: see Zimbra client host rejected: access denied and Zimbra error 450 4.7.1 for how to read those reject lines.
FAQ
Will a reverse DNS lookup rule stop all spam? No. It only checks the address of the connecting client; spam from servers with valid PTR records still arrives, so keep your spam filter rules.
Can a user on a laptop be blocked? Restrictions are applied to the client connection in the order listed. Users who log in through the submission service are normally authenticated, and an allow rule for authenticated clients placed first keeps them out of the check.
Do I need to restart all Zimbra services? The old post said so, but nothing in the manual or the guide requires it; the configuration daemon applies the change, and zmmtactl restart is enough to force it.
Comments
Post a Comment