I was having a hell of a time making entries in /etc/hosts in Leopard. I’d never had any issue in Tiger. Without getting into the details of the fairly complicated way that Leopard handles name resolution via DNS, directory services, and flatfiles (you can look elsewhere for that), it appears that Leopard is pretty picky aout where precisely you put entries in /etc/hosts.
A virgin /etc/hosts file looks like this in Leopard:
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost fe80::1%lo0 localhost
I thought it would make sense to put in my new IPv4 entries above the IPv6 entries (i.e., between the
broadcasthost line and the
::1 localhost line. Right? Wrong. If you put them there, your resolver will happily go on ignoring them until the end of time.
Put them at the bottom of the file and they’ll work.
Addendum 19 May 2009: I’m reading the O’Reilly book “Mac OS X for Unix geeks,” and here’s how to do it the OS X way:
$ sudo dscl . /Hosts/www.awfultimewastingsite.com ip_address 127.0.0.1
Note that /Hosts/ is not part of the filesystem — it’s part of the Directory Services local database.
The directory entries take precedence over /etc/hosts.
Popularity: 53% [?]