Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Because HOSTS file could only define static A records, is there a way I could inject a MX record/create arbitrary name into a Windows workstation DNS Cache service?


share|improve this question

No, not without running your own resolver on the workstation itself.

share|improve this answer
Or some other machine under your control. – Richard May 12 '09 at 10:19

MX-records are used by e-mail servers to find out which host(s) to send e-mails to for a domain name.

The Windows DNS cache (the "DNSClient" service) is populated whenever a program uses the Windows API "GetHostByName" (and a few other API functions).

However, there are no Windows API functions for retrieving MX-records - only for A/AAAA records and PTR-records (reverse).

Therefore e-mail servers have to do their own DNS lookups directly (via IP sockets etc.) - bypassing the Windows DNS cache.

So even if you could inject MX-records into the Windows DNS cache somehow, they wouldn't be used by your e-mail server.

The solution probably is to run a real DNS server program on the same computer as the mail-server and configure Windows / the e-mail server to use this. This allows you to configure MX-records (and other record types) directly for any domain name that you want. A nice choice would be Simple DNS Plus.

share|improve this answer

While you can't add mx records to a host file, you can "override" the address of the mail exchange. MX records point to host names so all you have to do is map the hostname of any MX record to an IP address in your HOSTS file.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.