Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

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

I'm using OS X Mountain Lion. I'm using dnsmasq to set up wildcard localhost domain names, such as, to point to localhost. But I have to add in my system preference -> network settings.

After I set up as the DNS server, the ISP's default DNS servers were over wrote by mine. This was preventing me from accessing websites. It's not a big deal when I don't move my computer, I could manually enter the ISP's DNS server. But if I change places, the ISP's DNS changes.

I also tried to use google's DNS server, but it's not working in some instance. How can I reserve (or update) the ISP's DNS server without deleting as a DNS.

Thank you in advance.

share|improve this question
up vote 10 down vote accepted

Yep. You can do this, /etc/resolver is your friend.

$ man 5 resolver:

Domain name associated with this resolver configuration. This option is normally not required by the Mac OS X DNS search system when the resolver configuration is read from a file in the /etc/resolver directory. In that case the file name is used as the domain name.

Simply put you can place nameserver inside a file you create called /etc/resolver/dev

You'll need to reload/restart. It'll then direct any requests to *.dev to your local nameserver.

Your network connection DNS remains on automatic, so it will cope with any changes in your environment.

Edit: I've just found and which have a few more details and include dnsmasq setup details.

share|improve this answer
It works, thank you – Daiwei Mar 27 '13 at 22:14

Is there a specific reason for using dnsmasq?

You could simply add entries to your /private/etc/hosts file leaving DNS pointed to whichever ISP you happen to be connected to. Here's how to do that using Terminal:

sudo nano /private/etc/hosts Enter you password when prompted.

Add any additions at the end of the hosts file (a single entry per line), for example:

Control + O and then enter to save the file within nano. Control + X to exit nano.

You'll than need to flush the local DNS cache using: dscacheutil -flushcache

share|improve this answer
Use hosts file can be a simple solution, but I need to setup wildcard domains such as *.dev to point to localhost. – Daiwei Mar 27 '13 at 22:12

Your Answer


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

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