8.8.2 - Mac Domains
Note: I wrote this for 10.3.9; under 10.4, things seem to work without the hoop-jumping described here. You can just use the GUI tool they provide and all seems to work well.
I often develop web sites before I associate the domain names with them so that the web sites are invisible prior to when I decide I want them public. Also, there are times I develop web ideas on web sites that will never be public.
Under linux, this is a snap: Edit the /etc/hosts file, add a line that specifies the IP address, name and the alias (example.com and www.example.com), and you're done. This is because linux uses the flat file /etc/hosts to define what name resolves to what IP address.
OSX can use flat files, but it has other options as well, and the defaults don't work very well for this type of use. Here's how you can fix that.
First, you need to either create, or edit, /etc/lookupd/hosts so that it reads:
LookupOrder CacheAgent NIAgent FFAgent DNSAgent DSAgent
This tells the DNS lookup daemon (lookupd) what order to use to resolve names. First, it needs to look in the cache, then look using Netinfo Manager, then use Flat Files (in other words, use /etc/hosts), and finally look using Apple's Open Directory server. I want to define my temporary and local server names using Netinfo Manager, so I put that right after the Cache lookup. Note that you'll need the administrator password to do this:
To create a new file:
sudo -s
echo "LookupOrder CacheAgent NIAgent FFAgent DNSAgent DSAgent" >> /etc/lookupd/hosts
Once that's done, you need to actually add the servers using the Netinfo Manager. That means open the tool, click on machines, add a NEW machine, change the "name" property to example.com, add a property "ip_address" with the appropriate value, add a property "serves" set to "./local"
You're half done. example.com will now respond from your local server (if you have a properly configured web server located there, of course.) Now you need to set up www.example.com exactly the same way:
Click on machines again, add a NEW machine, change the "name" property to www.example.com, add a property "ip_address" with the appropriate value, add a property "serves" set to "./local"
Now, if you've been fooling around with the name, your system's cache and/or your browser's cache may have the wrong IP address information stored. In order to clear this out, first open your browser, close any pages that point to the previously resolved page, open the preferences and clear the memory and disk caches. Now reboot your Mac. When the machine comes back up, you should be good to go.
Have a comment for me? Click here.