Dnsmasq and universal domain MX’s

Recently encountered a problem inside my network where local DNSmasq returned the same intranet IP for MX entries. This causes a feedback loop where mail is delivered back to the virtual machine where it originated.

To fix this, I configured DNSmasq with the following commands:


Internally, I have an unrestricted relay (another virtual machine) at These commands override the MX entry returned by DNSmasq for all entries in /etc/hosts.

If you use dig, it looks like this,

dig joshluben.com
joshluben.com 600 IN A

dig mx joshluben.com
joshluben.com 600 IN MX

Now you are asking why am I doing this? Because I have a dozen virtual machines inside my network, and some offer services outside my network, mobile devices like iPad’s, etc need consistency in the served domain entries to remain functional.