This is the second part of setting up a local DNS server for testing and development purposes. The first part was about configuring the DNS resolver so that it will use the locally running DNS server for the .test domain. This part is about setting up dnsmasq as a small local DNS server.

Installing dnsmasq

There are plenty of approaches, I am using Nix for this:

# As root, since I want to run it as a system service
nix-env -iA nixpkgs.dnsmasq

Configuring it

An example configuration could look as follows:

# Only for local use

# *.lab.test resolves to

# All others in *.test resolve to

# Don't forward queries regarding the test domain

Register it with launchctl

To run it as a system daemon the following steps were necessary:

cd /Library/LaunchDaemons
ln -s /var/root/.nix-profile/Library/LaunchDaemons/ .
launchctl load


The easiest is to run dig:

dig @localhost example.test

Use ping, curl or your Web Browser to check if the whole setup together with the DNS resolver configuration is working.


comments powered by Disqus