Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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

After I set up 127.0.0.1 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 127.0.0.1 as a DNS.

Thank you in advance.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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

$ man 5 resolver:

domain
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 127.0.0.1 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 http://serverfault.com/a/164215/163311 and http://www.echoditto.com/blog/never-touch-your-local-etchosts-file-os-x-again 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:

127.0.0.1 local.dev

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

 
discard

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.