Macos – Lion / name resolution order

dnsmacososx lionresolution

(this issue went away for me with the 10.7.1 update – /etc/hosts now works as always for me)

I've updated my Mac to Lion and now I notice that /etc/hosts is consulted last, even after DNS. This is very annoying as I have a lot of hostnames in there that I use for development.

Where is the name resolution order configured? I can check it using dscacheutil, so here's what a Snow Leopard machine tells me:

pilif@tali ~ % dscacheutil -configuration
DirectoryService Cache search policy:
    /Local/Default
    /BSD/local

Settings:
AAAA Queries  - Disabled (link-local IPv6 addresses)
Default TTL   - 3600
Policy Flags  - 0

And here is what Lion tells me

pilif@kosmos ~ % dscacheutil -configuration
DirectoryService Cache search policy:
    /Local/Default

Unable to get details from the cache node
Unable to get cache configuration information

aside of the two errors, I would assume that /BSD/Local is what makes it read /etc/hosts earlier.

Does anybody have any idea where this "Cache search policy" is stored and how to change it back?

I know that I can create host name entries using dcsl, but I'd really like to keep my /etc/hosts which I use on various machines.

Update: The resolution order can apparently be configured in the directory Utility. Unfortunately, this installations Directroy Utility doesn't list the BSD files any more in the Services tab.

Is this feature gone from Lion? Or is this installation hosed?

Best Answer

I solved the problem (and thus posting as an answer instead of amending the question):

The BSD files are indeed not listed in Directory Utility, nor in dscacheutil any more, but at least /etc/hosts is still read, but there is a problem in that multiple host names per IP address don't seem to be supported anymore or at least, they don't work right ATM.

When your old /etc/hosts could have looked like

127.0.0.1 localhost foo foobar

This would cause the ~10 second wait time to resolve any of these host names.

But if you use

127.0.0.1 localhost
127.0.0.1 foo
127.0.0.1 foobar

Resolution will be instant.

RedGrittyBrick's answer is also valid, but I specifically want to continue to use the hosts file over modifying the local directory as it's shared between various development machines of mine.

To answer the rest of my questions too (now all is clear to me):

  • The cache resolution order you configure in the directory utility where you can tell it which of the enabled directories you want to look at in what order.
  • To configure directories, also use the directory utility
  • The directory utility is launched by going to System Preferences > Accounts > Login Options > Join Directory > Directory Utility
  • In Lion, the BSD Files "directory" isn't available any more even though the help file still refers to it
  • As I said, /etc/hosts is still read, but there's the bug I described above.
Related Question