setting the DNS host name lookup order (a la /etc/hosts)
14 March 2005
There are several reasons you may want to change the hostname lookup order. Some people use the equivalent of the /etc/hosts file to thwart name lookups for offensive ad-serving machines on the Internet. Others of us just want to refer to a machine (usually a client's machine with a long fully-qualified domain name) with some shorthand.
This page describes that process. Rather than describing what you're doing, I'll show you exactly what to do.
I assure you that the UNIX commands I'll direct you to invoke have been taken directly from a Terminal window - these are the commands I just used to do a clean install - rather than having been composed after the fact. This is *exactly* what worked for me. I've taken pains to choose forms of the commands which should make sense to you even if you're new to UNIX.
You may use the command lookupd -configuration to see the current state of the lookup daemon. If the LookupOrder isn't as you like it, here's the process for changing it. (I want to have FF - flat files - used before Mac OS X looks elsewhere for hostname information.)
Specifying the lookup order in /etc/lookupd/hosts
% ls /etc/lookupd/hosts
ls: /etc/lookupd/hosts: No such file or directory
% mkdir -p /etc/lookupd
% sudo vi /etc/lookupd/hosts
insert LookupOrder Cache FF NI DNS DS and save
%
|
Restart the lookup daemon
Instead of rebooting the computer you can manually restart the lookup daemon like this:
|
% sudo kill -HUP `cat /var/run/lookupd.pid`
|
Backup, create, and load hostnames
% cd ~
% nidump -r /machines / > machines.original
% vi myHostnames
add files of the format 10.1.2.3 hostname and save
% sudo niload -v hosts / < myHostnames
|
Tweaking the hostnames
You can also tweak the hostnames with a GUI. Start /Applications/Utilities/NetInfo Manager and unlock the database. Then select the machines directory and edit entries in the canonical fashion.