On Linux, how do I fake an MX record for a domain?

I am testing two mail servers that live on two (virtual) machines with compiled domain names for emails. When one of the servers needs to send an email to the other, it apparently does a DNS lookup to record the recipient’s MX record, which does not point the sender server to the correct IP address, regardless of which IP / domain mapping I set to /etc/hosts .

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

+6
source share
1 answer

Assuming Ubuntu servers today typically use Postfix as their messaging agent, you can tell Postfix to disable DNS lookups for SMTP using disable_dns_lookups . Add the following line

disable_dns_lookups = yes

to the Postfix configuration file located in /etc/postfix/main.cf . This will force Postfix to look in /etc/hosts when it tries to resolve the domain of the mail recipient.

+4
source

All Articles