Description of problem:
Postfix sends different DNS queries for non FQDN relayhost in comparison to RHEL-7.
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. postconf -e relayhost = '[smtp]'
2. postconf -e postconf -e smtp_host_lookup=dns
3. postconf -e smtp_dns_resolver_options = res_defnames, res_dnsrch
4. send mail
Jun 25 09:36:26 host-01 postfix/smtp: 72F196EAA2: to=<firstname.lastname@example.org>, relay=none, delay=9006, delays=9006/0.04/0.02/0, dsn=4.3.5, status=deferred (Host or domain name not found. Name service error for name=smtp type=AAAA: Host not found)
On RHEL-7 it adds the domainname to the query, on RHEL-8 it doesn't, so just hostnames cannot be used for relayhost without workaround. As a workaround the following can be used:
postconf -e postconf -e smtp_host_lookup=dns
It maybe glibc bug.
It seems the resolver code has been rewritten in postfix-3.1.x and it now uses res_query instead of the res_search. From the manual page (the text was shortened):
> The res_search() functions make a query and waits for the response like res_query(), but in addition it implements the default and search rules controlled by RES_DEFNAMES and RES_DNSRCH.
> RES_DNSRCH If set, res_search() will search for hostnames in the current domain and in parent domains.
> RES_DEFNAMES If set, res_search() will append the default domain name to single component names—that is, those that do not contain a dot.
So that's why the RES_DEFNAMES and RES_DNSRCH flags are ignored now and domainname is not appended to the query. I asked upstream about purpose of this change.
Reply from upstream:
> # postconf -e "relayhost = [smtp]"
> # postconf -e smtp_host_lookup=dns
> # postconf -e "smtp_dns_resolver_options = res_defnames, res_dnsrch"
Those particular settings break the correctness of MX resolution and are not
Instead, use "dns, native" if you want those features for gateway
> Is this intended? I wasn't able to find any related incompatibility
> notice in the documentation
I don't think it was specifically intended, the change to use res_query was
made for other reasons, so this change may be inadvertent, but it is perhaps
time after 8+ years to drop the Postfix 2.8 support crutches.
According to the comment 7 I don't think it's worth to support the behavior of old postfix in RHEL-8 (we started with the postfix-3.3.x in RHEL-8 which already had this new behavior thus there was no regression) and divert from the upstream.
To sum it up:
- the change in behavior is side effect of resolver improvements
- upstream doesn't recommend usage of the configuration from comment 0 (usage of res_defnames and res_dnsrch resolver flags), for details see linked upstream documentation in comment 7
- the requested behaviour can be still enabled with the "smtp_host_lookup = dns, native" configuration
- it's not regression in RHEL-8, because postfix in RHEL-8 always worked this way
- I do not recommend patching the resolver to work differently from the upstream implementation just to mimic RHEL-7 behavior
Upstream finally acked it as a bug. The fix is as I wrote earlier - to replace the res_query by the res_search. The fix will be included in some future postfix release.
Created attachment 1645520 [details]
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory, and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.