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:


mx-target=192.168.1.3
localmx

Internally, I have an unrestricted relay (another virtual machine) at 192.168.1.3. 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 192.168.1.4

dig mx joshluben.com
joshluben.com 600 IN MX 192.168.1.3

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.