editing the hosts file

AlanCE

Registered
Hey all, I'm headed to Macworld next week and need to have 3 Mac OS X boxes running in a LAN but I need to be able to do TCP/IP connections by DNS name as well as IP address. We won't have internet access at the booth so no DNS can be set up. In macos 9 you could edit a Hosts file, inserting address records which would be querried by the OS prior to checking with a DNS server. I see that OS X has a hosts file in the hidden "etc" directory but I am unsure how to edit that. Is there some sort of GUI or do I just need to figure out how to edit this hidden file?
thanks!
 
i'm an idiot. yes of course I can use Term to edit the hosts file. But, my question still stands as to whether or not there is a GUI I should be using to add hosts to this file.
Thanks!
 
anyway... i thought /etc/hosts is used only in single user mode... I thought that's what it said in the file... sorry, but I'm feeling ab bit lazy to actually look at it...

in any case, can't you just use NetInfo for this? just add them under machines...
 
Interesting point. This is the content of my /etc/hosts file:

##
# Host Database
#
# Note that this file is consulted when the system is running in single-user
# mode. At other times this information is handled by lookupd. By default,
# lookupd gets information from NetInfo, so this file will not be consulted
# unless you have changed lookupd's configuration.
#
# 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

So it looks like it's only consulted in single user mode. I did a man on hosts and found that it's used as a backup for times when named isn't running. In Solaris and Linux, *nix variants that I have more experience with, /etc/hosts is normally looked at first. The order is determined by /etc/resolv.conf on those systems. It looks like you can do it that way with darwin but it's not the normal way to do it.

Anyway, the answer to this isn't obvious to me. Maybe simx will chime in? He seems to be pretty *nix savvy.
 
Originally posted by beef
in any case, can't you just use NetInfo for this? just add them under machines...

Hm, yeah I guess so. I started making a new machine entry but ran into one field I don't know if/how to replicate. It is the "Serves" property, I am guessing i should use ./Local just like localhost but I dunno since I have no clue what that property is for :)

I got this from maccentral:
niload -m hosts / < /etc/hosts
He says it forces the hosts file to be loaded, I'll try that next if my machine/netinfo changes don't do the trick.
 
as far as I know, you should set "serves" to "../network"

I have used ./local before, too. And it did work, until I've made other modifications. Setting other machines to ../network has never resulted in any errors (if things are messed up, there will be a huge delay at "starting directory services" on startup)

I haven't read enough on NetInfo, but my guess is that if it's not localhost, you shouldn't be setting it to ./local

so, anyway, I recommend you set it to ../network

if you learn more about NetInfo in the process and have better understanding of this, let me know.
 
Back
Top