I'm currently migrating a website to another server, and want to test the DNS configuration (more specifically, email MX records) before moving the domain over. I've configured the DNS on the new server to have MX entries for Google Apps in the same way that it's configured on the old server. The domain is controlled by nameservers on the old server at the moment, so the change would simply be updating the nameservers to the new servers. (What I'm getting at is DNS is controlled at the server level, not registrar level).

Since the website has quite a number of users, I want to make sure the configuration is right before flicking the switch. For this, can I add an entry to the hosts file of my local computer to point the domain to the new server? I've done this, and the web server works, but would this also test the email MX records on the new server?


Do not use the hosts file for this; it replaces DNS lookups rather than doing them (and the ns1 subdomain has no special meaning).

On linux, you can use dig to test DNS; do dig @ in mx yourdomain.tld where yourdomain.tld is replaced by your domain and the example IP is replaced by that of the nameserver under test.

On windows, use nslookup - and enter the query mx yourdomain.tld.

  • I'll just note that there's nothing stopping you from using dig on Windows as well (it just isn't shipped with Windows) – Håkan Lindqvist Mar 28 '15 at 9:58

No, /etc/hosts is only used for address lookups. You need to modify the configuration of your resolver to point to the new name servers.


It is OK to effectively change your configuration, perform the test, and then roll back (if needed). Because of cache mecanism, the number of impacted user will be very low.

I remember experiencing problem with one of my DNS server, one user told me it was broken about 1 hour after it was broken. At that point, I called another user I knew he was using the corresponding RR (he was connected to the corresponding web service) and all worked fine for him (RR still in cache).

Using the hosts file is not a proper way to test your configuration as it completely bypass the resolution mechanism. The best way to test your DNS config is to expicitly ask the wanted DNS server

dig @wantedserver <other_option> mydomain

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.