10

I'm testing two mail servers that live on two (virtual) machines with made up domain names for emails. When one of the servers needs to send an email to the other one, it seemingly performs a DNS lookup for the recipient domain's MX record, which doesn't point the sender server to the correct IP, no matter what IP/domain mapping I put in /etc/hosts.

So should I install a DNS server and create a custom MX record for the recipient domain? How do I do this on Ubuntu 12.04 or is there an easier way?

1 Answer 1

10

You don't actually need to set up MX records for email delivery. 'A' records will do the job as well. See "Fallback to the address record" at Wikipedia about MX records.

In order to make fake hosts in /etc/hosts working for Postfix, you must tell it to actually use that and not just DNS-only by setting smtp_dns_support_level = disabled in /etc/postfix/main.cf. See the postconf documentation for details.

Alternatively, you could configure your MTA (e.g. Postfix) to use a specific transport for a domain. For Postfix use transport_maps.

3
  • I tried to make it fallback by blocking the DNS port 53 which worked only partially: instead of resolving to an incorrect recipient IP using an MX record of some internet DNS server that is unknown to me, it now doesn't resolve at all: status=deferred (Host or domain name not found. Name service error for name=example.com type=MX: Host not found, try again). Sure example.com is set to the correct IP in etc/hosts. Nov 20, 2012 at 13:10
  • @DesmondHume I've updated my answer for Postfix to use the native host lookup on your system.
    – gertvdijk
    Nov 20, 2012 at 13:24
  • 3
    Adding disable_dns_lookups = yes to /etc/postfix/main.cf did the job (smtp_host_lookup = native did not). Thanks a bunch. Nov 20, 2012 at 13:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .