We've got several machines set up with DNSMasq to run local development environments forwarding all .dev requests to

However we need to add some exclusions to this list, wondering how we'd go about it.

All these exclusions are still internal IP addresses, which are resolved by an internal DNS server, say on

For example we'd want to exclude any subomain or domain that has batcave.dev in it.

So batcave.dev would use the dns server on and resolve to what ever is setup in the DNS server, along with other entries like wiki.batcave.dev and phpmyadmin.batcave.dev there could be any number of these subdomains.

We're running OSX/macOS & currently our resolver file from /private/etc/resolver/dev has just nameserver in it.

Then our /usr/local/etc/dnsmasq.conf has this added to the bottom


You can see the full files at https://gist.github.com/OwenMelbz/80c68e836058959b87f86f242e6efffa if needed :)

1 Answer 1


If I understood your question correctly, then what you are looking for is the -S option on the command line:

    This is intended for private nameservers:
    if you have a nameserver on your network which deals with
    names of the form xxx.internal.thekelleys.org.uk at then giving the flag
    -S /internal.thekelleys.org.uk/
    will send all queries for internal machines to
    that nameserver, everything else will go to
    the servers in /etc/resolv.conf.

Then,in your case it World be something like

    -S /batcave.dev/

or on the config file


Hope it helps!

  • 2
    If we just want to not manage which IP gets assigned to those exceptions, specifying server=/domain/# makes dnsmasq ignore this DNS request and pass it to following DNS servers.
    – jesjimher
    Jun 21, 2018 at 12:37
  • @pablo could you explain a little more about the -S ? where does this go for example? And currently, that assumes the DNS server is - Unless I'm misunderstanding currently the solution is the opposite to the question. This just defines a new resolver, rather than allowing you to exclude stuff? What happens if you don't know the IP of the DNS server you need to resolve and you just want DNSMasq to ignore it e.g exclude
    – owenmelbz
    Jun 24, 2018 at 17:10
  • 1
    Yes, my proposal is diverting the special requests to a known nameserver, not ignoring them. It seems that @jesjimher is providing a more appropiate option (which I did not know, by the way, thanks jesjimher)
    – Pablo
    Jul 31, 2018 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.