Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Define hosts via the hosts file in 10.2 Network
In Mac OS X 10.1.x, the host table was disabled so that it was quite difficult to add host aliases (eg: "flare" is the alias I use for 192.168.0.2 on my home network). It was possible to do it using NetInfo, but it was not very clear how to do it and was very error prone.

In OS X 10.2 (Jaguar), the hosts table is now active ... even though the hosts file itself says that it only works in single user console mode. So, if you're in a hurry to add hosts that Rendezvous can't find, then simply edit your /etc/hosts file (as root) and add lines for each host alias.

But wait, there's more. It turns out that there's an even better way to do it. Simply create a temporary hosts table file with the extras and then use the niload command to add your host entries directly to NetInfo. This is especially helpful because you can copy a hosts table from some other machine on your network and use niload to import all of the entries for you.

Credit for this hint goes to bnenning, who posted it as part of a response to my Apple Slasdot posting.
    •    
  • Currently 3.33 / 5
  You rated: 4 / 5 (3 votes cast)
 
[22,545 views]  

Define hosts via the hosts file in 10.2 | 4 comments | Create New Account
Click here to return to the 'Define hosts via the hosts file in 10.2' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
nothing new...
Authored by: aaronfaby on Aug 29, '02 09:36:30PM

This could also be done with 10.0+, but you have to edit some lookupd config files. Basically you can tell lookupd the order of preference in which to lookup information. By editing the config files you can tell lookupd to look in the text files in /etc before going to the netinfo db to get information.

Do a 'man lookupd' for more information.



[ Reply to This | # ]
more on setting up hosts…
Authored by: bruddahmax on Aug 29, '02 11:26:57PM
some like to set up hosts to block all annoying ad content (ie servers that litter ads vs. tastefully display ads on the better sites) to cut down on network chuttle. i did the routine described at the linked site in both 10.1 and 10.2 and it has worked well each time. loading of the hosts file into NetInfo Manager through the terminal takes absolutely forever (30+ minutes) but it will block just about all annoying ad servers. here's the link. ( http://www.macwrite.com/criticalmass/mac-os-x-hosts-revisited.php )

[ Reply to This | # ]
More details and 10.4 info
Authored by: markcrocker on Jul 03, '05 02:01:00PM
Upgrading to Tiger has broken lots of stuff for me including my hosts, and revisiting my own hint made it clear that the hint didn't quite have enough information because the niload man page wasn't very clear on what the domain should be. So, just to make it clear, the actual command is something like this:
sudo niload -m hosts . < /Users/mcrocker/tmp/hosts
where the last part should be replaced by the path to your old POSIX style hosts file. You can also skip the file and redirect character and type host entries in manually. Another gotcha is that you have to be the administrator to do this, and depending on how you did your upgrade to 10.4 (Tiger), you may find that the Administrator account no longer has a password. You can set this by running the installation CD again and selecting the reset password option from the tools menu rather than continuing with the actual install.

---
Jaguar -- you know, the one with the Leopard spots.

[ Reply to This | # ]

Define hosts via the hosts file in 10.2
Authored by: poslfit on Dec 19, '09 05:29:41PM

For life in the post-NetInfo 10.5 and 10.6 world, see http://jonathan.tron.name/2008/01/05/hosts-aliases-in-leopard .



[ Reply to This | # ]