Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (45 sloc) 1.92 KB

Set up a local test domain with dnsmasq

Use the .test TLD

RFC-2606 reserves 4 different TLDs for testing and documentation examples:

  • .test
  • .example
  • .invalid
  • .localhost

It also reserves these second-level addresses:


Set up dnsmasq and resolvers

  1. Install Homebrew and Homebrew Services if you haven't already.

  2. brew install dnsmasq, edit its config (/usr/local/etc/dnsmasq.conf, assuming your brew --prefix is /usr/local) and enable only these options:

  3. Create /etc/resolver directory, and add (dnsmasq) as nameserver for our TLDs:

    % sudo mkdir -pv /etc/resolver
    % sudo bash -c 'echo "nameserver" > /etc/resolver/localdomain'
    % sudo bash -c 'echo "nameserver" > /etc/resolver/test'
  4. System Preferences > Network > Wi-Fi > Advanced… > Search Domains > add localdomain to the list.

  5. Start / restart dnsmasq and check that it is listening. Ping to test.

    % sudo brew services restart dnsmasq
    % lsof -Pn -i | grep LISTEN
    % ping foo
    PING foo.localdomain ( 56 data bytes
    64 bytes from icmp_seq=0 ttl=64 time=0.033 ms
    % ping foo.test
    PING foo.test ( 56 data bytes
    64 bytes from icmp_seq=0 ttl=64 time=0.044 ms
    % dig @ foo.test


You can’t perform that action at this time.