Re: force postfix to look at hosts file first On Wed, Feb 13, 2008 at 01:00:45PM +0100, Martin Schmitt (Schmitt Systems) wrote:

> Victor Duchovni schrieb:
> 
> > By default Postfix explicitly uses
> > DNS, as explained in a previous response. The "solution" for sites with an
> > nsswitch that does "files, dns" and want Postfix to do the same is to use:
> > 
> >     smtp_host_lookup = native
> 
> The hidden question, though, is whether there is anything wrong with the
> docs. From 2.5.0, postconf(5):
> 
> disable_dns_lookups (default: no)
>        Disable DNS lookups in the Postfix SMTP and LMTP clients. When
>        disabled,  hosts  are  looked up with the getaddrinfo() system
>        library routine which normally also looks in /etc/hosts.
> 
>        DNS lookups are enabled by default.
> 
> smtp_host_lookup (default: dns)
>        What mechanisms when the Postfix SMTP client uses to look up a
>        host???s IP address.  This parameter is ignored when DNS lookups
>        are disabled.
>        [...]
> 
> Apart from the fact that the english syntax in the description of
> smtp_host_lookup has been slightly garbled since at least 2.1.3, what is
> the proper interpretation of these two along each other?

The "disable_dns_lookups" parameter, is in fact "disable MX lookups" +
"smtp_host_lookup = native". While "smtp_host_lookup" just changes how
MX host IP addresses are resolved, it does NOT disable MX lookups.

The "disable_dns_lookups" parameter is largely obsolete. It is only
needed in non-Internet connected environments where DNS is unavailable.
It used to be recommended for content_filter smtp transports, to avoid
latency due to address rewriting that canonicalized (replaced CNAME
LHS with RHS) host names in ervv@domain email addresses. With RFC 2821
no longer requiring the domains in email addresses to not be CNAMEs,
such rewriting is no longer done as of approximately Postfix 2.0.

Bottom line, if one wants to use non-DNS host names in SMTP nexthops,
the right setting is "smtp_host_lookup = native". A better solution is
use a private DNS zone for such names.

named.conf:
    zone "localhost" in {
      type master;
      file "localhost";
    };

localhost:
    $TTL    2D      ; Default TTL
    @       IN SOA  localhost.      Postmaster.localhost. (
			    1      	    ; Constant serial, no slaves
			    10800           ; Refresh after 3 hours
			    3600            ; Retry after 1 hour
			    604800          ; Expire after 1 week
			    3600 )          ; Minimum TTL of 1 hour
    @       IN NS   localhost.
    @       IN A    127.0.0.1

    ; Private DNS records
    gw.example.com.localhost.	IN A 192.0.2.1

Then in the transport table:

    example.com	relay:[gw.example.com.localhost]

This way everything is in DNS, and can even do "load balancing" with MX
records or multiple A records.

-- 
	Viktor.

Disclaimer: off-list followups get on-list replies or get ignored.
Please do not ignore the "Reply-To" header.

To unsubscribe from the postfix-users list, visit
http://www.postfix.org/lists.html or click the link below:


If my response solves your problem, the best way to thank me is to not
send an "it worked, thanks" follow-up. If you must respond, please put
"It worked, thanks" in the "Subject" so I can delete these quickly.


