Is there an OSX way to create a Classic Hostfile?

kryptonomous

Registered
Where I work, we host two web sites internally. Because of the way our network is set up, I had to create a Hosts file for TCP/IP (an A-Record that returned an IP address for a host name ex. www.domainname.com A 00.00.0.00)

That worked fine in Classic, but when I installed OS X a couple of years ago, it doesn't work. I have to start up Classic and use my Classic browser whenever I do maintenance on these sites and it annoys the jeebies out of me.

Anyone know a work around for this in OSX Jaguar? Is this something I can set up in NetInfo?

I called Apple Support and they said this sort of help wasn't covered under AppleCare, but recommended I hit the Support section on Apple.com -- thanks guys! //insert sarcasm here//

I've spent many hours there to no avail. If anyone has any suggestions it would be swell.

=)
Thanks!
 
Under Jaguar, flat files are consulted first, so /etc/hosts would be the first item consulted, unless you change the lookup order of lookupd.

If you add "NIAgent" to the lookup order, you can add machines entries (host entries) with NetInfo Manager in the GUI or via the command line:
sudo -s
niutil -create . /machines/BigMac
niutil -createprop . /machines/BigMac ip_address "192.168.1.2"
niutil -create . /machines/Sidecar
niutil -createprop . /machines/Sidecar ip_address "192.168.1.3"

Restart lookupd to register these changes:
kill -HUP `cat /var/run/lookupd.pid`
exit


[Under 10.1, if FFAgent (Flat File Agent) is in the lookup order of lookupd, /etc/hosts will be consulted for hosts entries, but usually NetInfo (NIAgent) is the first to be consulted in the lookup order so it is generally preferred to put hosts information within the NetInfo facility, rather than using the flat file.]
 
Thanks for your help. Unfortunately it didn't work for me. I need my computer to return an IP address for a domain name. I used the commands you have here, replacing BigMac with the actual domain name (for the sake of example, bigmac.com).

When I typed:
niutil -createprop . /machines/bigmac.com ip_address "100.0.0.100"

I received this error message:
can't connect to server for domain ./machines/bigmac.com

At least this info is now here in case anyone else can use it! I do appreesh your help.
 
You need to put a space between the . and machines: niutil -create . /machines/BigMac
The . refers to your NetInfo domain; in this case it is '.', or your local machine.
You could also use / instead: niutil -create / /machines/BigMac

Also, you need to change the default lookup order of Jaguar to get lookupd to notice the entries:
sudo -s
echo "LookupOrder CacheAgent NIAgent FFAgent DNSAgent DSAgent" >> /etc/lookupd/hosts
exit


or

sudo niutil -create . /locations/lookupd/hosts
sudo niutil -createprop . /locations/lookupd/hosts LookupOrder CacheAgent NIAgent FFAgent DNSAgent DSAgent



 
Back
Top