If you’ve been following along in the OS X Caching Only Name Server series of articles, you should now have a running BIND daemon and be ready to start using it.
Configuring an interface to use a local DNS server via the Network Panel in System Preferences is pretty straightforward. As you can see in this image (I’ve circled the change in red), you merely add ‘127.0.0.1′ in the text box labeled ‘DNS Servers:’. After applying the change, your BIND dns server running on 127.0.0.1 will be your primary DNS server.
If you need to make the change on a remote system, things are slightly more complicated. If you only have shell access (preferably via SSH), then you’ll want to take some time to learn a bit about an application called ncutil.
The first thing you must realize about OS X network configuration is settings such as DNS are tied to network interfaces assigned to locations. Thus, if you have multiple locations, but want to make a setting change to the Built-in Ethernet interface, you have to make the change in each location. The default location is ‘Automatic’. The very first thing we’re going to do is take a look at the DNS values saved in the ‘Automatic’ location for our ‘Built-in Ethernet’ interface. As always, the ‘$’ represents the shell prompt and should not be typed.
$ sudo ncutil read "Automatic/Built-in Ethernet/DNS"
$
As you can see, it doesn’t return anything. This interface is configured to use DHCP and does not have any pre-configured DNS settings. OS X stores the DNS server settings in an array called ‘name-server’. Using the ncutil command, we can add our local DNS server value (’127.0.0.1′) to the ‘name-server’ array. Then, let’s read the value back to verify the change. (Please note, each command should be on a single line. Formatting may cause a line to wrap on this page.)
$ sudo ncutil addval "Automatic/Built-in Ethernet/DNS" name-server 127.0.0.1
$ sudo ncutil read "Automatic/Built-in Ethernet/DNS"
-rw name-server = {
127.0.0.1
}
Perfect! Now we just need to save our changes so that the new settings will go into effect.
$ sudo ncutil apply-changes
That’s all there is to it. You have successfully updated your OS X network settings to use a local DNS server.
Related Reading:
- Mac OS X Tiger for Unix Geeks by Brian Jepson, Ernest Rothman
- Learning the bash Shell by Cameron Newham

Get Slaptijack updates delivered to your Inbox or RSS Reader for free!
June 7th, 2007 at 8:33 am
[...] Updating OS X Network Settings to Use a Local DNS Server [...]