Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 127.0.0.1
$ ping test1
ping: cannot resolve test1: Unknown host
# OK, that did not work
$ sudo dscl localhost -readall /Local/Default/Hosts IPAddress
IPAddress: 127.0.0.1
RecordName: test1
$ sudo dscacheutil -flushcache
$ ping test1
ping: cannot resolve test1: Unknown host

What am I not getting here?

share|improve this question

1 Answer 1

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
1  
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

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.