I do web development and I would like to have dnsmasq running and handing my local dns requests. However I work in a lot of different networking scenarios and I need to DHCP updating my networking information multiple times a day.

I already have dnsmasq running and I can have my laptop always use it by setting the DNS name server.

It's not too bad, this way, I can use the location management (in the network preference pane) and just switch location between 'Automatic' and 'Automatic (dnsmasq)' when I need to, however what I really want it something linux has.

In linux I can configure my dhcp client to prepend a name server to whatever I get from dhcp. On ubuntu I do this by editing /etc/dhcp3/dhclient.conf and setting.

prepend domain-name-servers;

Is there an equivalent in OS X (10.8 Mountian Lion). Thanks

1 Answer 1


As you already know, OS X will overwrite any changes you make to /etc/resolv.conf so you can't really specify your own nameserver in there. Luckily, there is a way to add your own resolver entries in a way that will persist whatever network connection you use whilst still using DHCP assigned name servers for most normal lookups.

Create the directory /etc/resolver and create a text file within it that simply has a standard name server directive like nameserver Make sure this text file is named the same as the domain or TLD you wish to use dnsmasq for. In my case, all my development sites end with the .dev TLD so my config file is named /etc/resolver/dev.

And that's it! From now on, when ever you connect to a network using DHCP, your name servers will be automatically assigned and used as normal but any requests for your specified TLD (*.dev in my example) will be routed to dnsmasq.

  • That sounds great but, I can't get it to work. In my case I've been using .loc as a TDL so I setup /etc/resolver/loc. I setup the files how you suggest but when I run dig frankie.loc I do not get an answer but when I run dig @ frankie.loc I do.
    – Jachin
    Mar 29, 2013 at 20:16
  • Oh, wait, dig didn't work, but ping did. So it does work, thanks a lot, this is exactly what I needed.
    – Jachin
    Mar 29, 2013 at 20:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .