I just want to add my own list of Search Domains but without overriding the ones returned by the DHCP?

As anyone would imagine I already tried to add them to Network > Advanced > DNS but adding them there it will override the ones from DHCP, which is not my intend.

It would be perfect if I could add them after the ones form DHCP, but I would also accept a solution that adds them after.

2nd try would be /etc/resolv.conf but the message from the file is as clear as it can be:

# This file is not used by the host name and address resolution
# or the DNS query routing mechanisms used by most processes on
# this Mac OS X system.
# This file is automatically generated.

Personally, I would send the guy who wrote this message to do some phone support for two months. So, he would learn to add some hints next time he documents things: where are you supposed to tune the settings? or include a link to a knowledge base article.

Still, I don't want something that is lost on minor OS X update.

How can I do this for OS X 10.7 ?

  • 1
    You might explain a bit more what you've tried and why entering search domains in the normal place isn't what you want. Specifically - do you want your search domains to be searched before the DHCP ones or after the supplied ones? – bmike May 11 '12 at 19:27

Perhaps try adding/appending them to /etc/resolv.conf? You cannot add them to the end of the list manually, delimiting with a comma in Lion? It seems to work in 10.6, it adds it in addition to the DHCP supplied ones, and the entire lot of them show up in resolv.conf instantly.

Perhaps this won't work for your purposes, but why not just manually add the ones DHCP supplied and the ones you want to add and save them in System Preferences? Then you won't need to worry about overwriting anything as you will be manually adding them. I don't suppose your domain is going to change names very frequently.

I can tell you as of Snow Leopard mDNSResponder (Bonjour) handles all the DNS (not just Multicast DNS).

  • resolve.conf usage is deprecated, being documented inside the file. – sorin Mar 5 '15 at 11:33
  • This doesn't work and should not be the accepted answer. @Yobert's answer works great and does exactly what the asker wanted. – JakeRobb Mar 6 at 18:15

You could use the networksetup command, and add the additional search domains in an array on the comand line: From the man page:

-setsearchdomains networkservice domain1 [domain2] [...]

Use this command to designate the search domain for the specified
<networkservice>. You can list any number of search domains
(replace domain1, domain2, and so on with the name of a local
domain). If you want to clear all search domain entries for the
specified network service, type aemptya in place of the domain


sudo networksetup -setsearchdomains Wi-Fi legacydomain.com secondlegacydomain.com additionaldomain.org evenmoresearchdomain.net

this invocation should have the proper order.

  • 3
    While I love the command line approach I have to say that running this does override the DNS domains received from the DHCP server, so is not a proper solution. I still want to be able able to used them, just to add mine on top of bottom of the list. Need an automated solution. – sorin Mar 5 '15 at 11:34

Just put a file in /etc/resolver/ with a name such as "searchappend" with these contents:

search example.com

Just don't name the file "com" or some other valid TLD. This works because of OSX's resolver magic. For more info, read through https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man5/resolver.5.html

I have a file there called "consul" that looks like this:

port 8600
search consul

That magically makes it so .consul is appended to the search path, and any resolving for .consul TLDs uses my local nameserver.

  • Links broken, cannot find a replacement. – slm Oct 17 '18 at 11:43
  • I agree that the links are broken, but this worked for me on 10.13.6. I had to create /etc/resolver first. The file I created contained only search mydomain.com. The additional search domain applied to all network adapters and appended to the existing DHCP search domains. – JakeRobb Mar 6 at 18:13
  • This doesn't work for me anymore in Mojave. :( – JakeRobb Aug 21 at 14:03
  • You may be able to do man 5 resolver on your mac? the link was to a web version of that same man page. – Yobert Sep 13 at 20:47

Add them to System Preferences > Network > Advanced > | DNS |

(Any particular reason for this being down-voted? It does exactly what the requester is asking for and doesn't require the use of a Terminal.)

  • 2
    Because he wrote that he didn't want to override the DHCP DNS entries. Plus you would have to add them to every interface. – joelpittet Jun 29 '12 at 5:10

Assuming your router provides its set of DNS servers, add its IP address (your router’s) to your DNS Servers list. Add your own DNS servers below it.

Your computer will query your router first, then cycle through the ones you defined manually.

You must log in to answer this question.

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