Super User is a question and answer site for computer enthusiasts and power users. 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 read a few places that dscl is preferred over /etc/hosts for adding hostnames (for instance when developing). But in Mountain Lion (OS X 10.8) I cannot get it to work (others too). I have read others that report other changes in 10.8 that affect dscl too. Anything I can do to make it work?

$ sudo dscl localhost -create /Local/Default/Hosts/test1 IPAddress
$ ping test1
ping: cannot resolve test1: Unknown host
# OK, that did not work
$ sudo dscl localhost -readall /Local/Default/Hosts IPAddress
RecordName: test1
$ sudo dscacheutil -flushcache
$ ping test1
ping: cannot resolve test1: Unknown host

What am I not getting here?

share|improve this question

Local OpenDirectory Hosts are no longer working on Mountain Lion (and possibly Lion). My guess is that this stopped working when they moved from DirectoryService to opendirectoryd.

Hopefully /etc/hosts can still be used in your environment.

share|improve this answer
Cool. Any background info (like a link to this)? – oligofren Mar 13 '13 at 10:47
I'm not sure if this is intentional. Perhaps you should create a bug report for this. – gusto Mar 17 '13 at 23:01

You must log in to answer this question.

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