Yu Jiaao
Yu Jiaao

Reputation: 4714

Can I resolve a MX record using hosts file?

To test mail server I need an MX record in DNS server, it always with a delay because DNS cache, I need to make it faster. Is there a way make an MX record locally like A record by etc/hosts file?

Upvotes: 4

Views: 16746

Answers (2)

Thanks, this works.

echo "10.10.10.1 mail.example.com" | sudo tee --append /etc/hosts > /dev/null

echo "disable_dns_lookups = yes" | sudo tee --append /etc/postfix/main.cf > /dev/null

systemctl restart postfix

Upvotes: 2

davidea
davidea

Reputation: 21

i'm managing to use postfix on a proxmox server to delivery the mail to a local mail server on a vm , with a different ip address from the dns mx record, i've found very useful this article, http://www.readonlymaio.org/rom/2018/01/16/force-postfix-to-search-mx-records-in-etc-hosts-file/

he leds me to disable the dns lookup in postfix to force it to use the hosts A record !!

it works

in the hosts X.X.X.X example.com

Edit the /etc/postfix/main.cf file and add this line:

disable_dns_lookups = yes

after, restart postfix

Upvotes: 1

Related Questions