Adding my own entries to /etc/hosts and getting them to WORK!

  • Thread starter Thread starter Bes
  • Start date Start date

Bes

Bes

Soldato
Joined
18 Oct 2002
Posts
7,318
Location
Melbourne
Hi,

As per title, just adding to /etc/hosts is not enough, and as there is no nsswitch.conf to configure looking up in files first, how am I supposed to do this?

Thanks
 
I've just looked through my official Apple OS X training manuals (Desktop and Server books) and there is no mention of how to configure /etc/hosts

Given the UNIX core it should be possible but I am also not sure.

Sorry.
 
Editing just that file worked for me in the past. Has some recent version of Leopard changed things?
 
Should be the opposite, host file usage should work as it would on a standard Unix platform so just edit the file and try and ping the host, (note that if you can't get to an address you added through Firefox then take that offline and online again to flush it's IP cache ... other applications may have similar issues).

On earlier versions you may have had to tell lookupd to use a host file using the niutil command but that shouldn't be needed now.

In fact I've just checked by adding a host to /etc/hosts on my Leopard install and, apart from having to remember to use sudo when editing the file, it worked exactly as expected and the host was immediately resolvable (and this is an internal host which is definitely not in DNS).
 
Ok so I added mysite.mac<tab>localhost, rebooted, and it is unreachable... What gives?
 
Ok so I added mysite.mac<tab>localhost, rebooted, and it is unreachable... What gives?

That syntax is wrong. Host file entires should have the syntax:

ip-address fully-qualified-domain-name short-name

where you don't have to have both the names but for completeness you should. The purpose of the entry is to relate an ip-address to a hostname, you are not doing that in your example.

e.g.

192.168.0.5 memyselfandi.overclockers.co.uk memyselfandi

will resolve memyselfandi (or memyselfandi.overclockers.co.uk) to 192.168.0.5. Note that the localhost entry in this case should only be against the loopback address, i.e.

127.0.0.1 localhost
 
Back
Top Bottom