This is mostly for my own reference, this document has been sitting in my drafts folder since … like two years ago.
First of all, OSX claims .local
for Bonjour and will treat them differently, so use .dev
or something instead.
To add a host called myapp.dev
and point it to localhost
, just do this:
sudo dscl localhost -create /Local/Default/Hosts/mydev.dev IPAddress 127.0.0.1
To see all the currently defined hosts and their IPs:
sudo dscl localhost -list /Local/Default/Hosts IPAddress
And to remove a host:
sudo dscl localhost -delete /Local/Default/Hosts/mydev.dev
if you declare both a IPv4 and IPv6 address in /etc/hosts
for a .dev
domain like so:
27.0.0.1 myapp.dev
::1 myapp.dev
Then it should work correctly.