Birds Like Wires

Feed the Birds

Mac OS X Server and DNS

I’ve just bumped into this little chestnut again, and thought it would be worth documenting quickly, once and for all.

If you run Mac OS X Server, the one thing that is more important than anything else is to make sure the DNS hostname is set correctly. It’s fundamental – everything breaks if it’s not working. Out of the box, Server even configures its own DNS server to make sure the details are correct.

Now, I run my own internal DNS using Mac OS X Server, just so I don’t need to remember IP addresses. However, after adding an address to the DNS yesterday, the hostname of the server magically changed. I didn’t ask it to, it just happened. It was time to break out the repair tools.

Three Commands Will Save You

They are changeip, scutil and dscacheutil. Remember them, because they are your only friends. If the DNS is iffy, Server Admin runs away and needs some coaxing to play again (which, of course, is really helpful).

First, make sure that your IP address is correct. Please tell me you’re using a static IP? Yes? Good. If that’s not the issue, fire up and find out what’s going on. My first hint was that the hostname next to my command prompt had changed, which is a pretty big clue. Run:

$ sudo changeip -checkhostname

This tells you what the hostname is and what the system believes the hostname should be via DNS. If there’s been a simple misunderstanding where the DNS is correct and the Current HostName just doesn’t match, issue this:

$ sudo scutil --set HostName correct.hostname
$ sudo dscacheutil -flushcache

You should be good to go again. If your DNS is wrong, the easiest solution is to get Server Admin out of the corner. Fire it up (it will take ages if the DNS is broken) and reconfigure the connection to your server using the IP only (or if running on the local machine). This should give you access to correct the DNS mistake. Then repeat the commands above, starting with changeip to determine if everything is working.

$ sudo changeip -checkhostname

Primary address     =

Current HostName    = correct.hostname
DNS HostName        = correct.hostname

The names match. There is nothing to change.
dirserv:success = "success"

Encourage DNS

I did once have a situation where the DNS in Server Admin was correct, but the DNS server wouldn’t start via the app. The way to deal with this is again in

$ sudo serveradmin status dns
dns:state = "STOPPED"
$ sudo serveradmin start dns
dns:state = "RUNNING"
$ sudo dscacheutil -flushcache

Then make sure you can ping things and the lookup works.

$ ping correct.hostname
PING correct.hostname ( 56 data bytes
64 bytes from icmp_seq=0 ttl=64 time=0.055 ms
64 bytes from icmp_seq=1 ttl=64 time=0.079 ms
64 bytes from icmp_seq=2 ttl=64 time=0.067 ms
--- correct.hostname ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.055/0.067/0.079/0.010 ms

$ host domain name pointer correct.hostname.

If you’ve made it to that point, reboot and cross those fingers.

← Recent Articles
, ,