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?