There's a specific remote subdomain mymachine.home.com whose the IP changes on all the time that I need to update DNSMasq to have it resolve correctly.

But I tested pinging xxxxxx.home.com which doesn't exist and it all seems to want to point to my NginX reverse proxy. (A lot of my entries point there.)

How can I stop DNSMasq from resolving non-existent subdomains to a local IP? (It's always the same IP)


How can I tell DNSMasq to always use external DNS for a specific entry?

This is my installation Configuration.

#Dont use external file for custom dns
#Use this file for DNS nameservers (contains googles DNS)

#PING home.com =

#Listen only on eth0
#DHCP Range (12hr lease time)
#Change DEFAULT GATEWAY (Default is same IP as DNSMasq Server)

#STATIC IP to 2 MAC Address that WILL NOT be used simultaneously [IE: Laptop with WiFi + LAN]
#Assign STATIC IP by MAC
  • The first question would be the preferred method of resolving this for all subdomains, or answer 2 would require manual intervention for each remote subdomain, but I don't have many remote subdomains, so I'm fine with a work-a-round type fix :P, thanks! Commented Jul 14, 2016 at 0:51
  • I don't understand the question. Which domain do you want to change, and what did you put in the configuration file to make it resolve to a local IP? Post your complete dnsmasq configuration and a precise example of bad resolution: the actual output of dig on the host name (with consistent mungine), and what it should be instead. Commented Jul 14, 2016 at 21:23
  • Its not that complicated, basically, subdomains that do not exist all point to, I have a remote subdomain, that if I don't have an entry, it points to, but the issue is, the remote IP changes, so I have to update my local DNS entry with the remote IP every time it changes. I want to just remote the entry all together and use Google DNS, but if I remove the entry, it points to .. I posted a link to my entire Configuration, I will post dig later, but I'm at work ATM. Commented Jul 16, 2016 at 14:52
  • You mean that all queries for non-existing domains return I don't think dnsmasq even has a feature to do that. It's something that some ISPs do (to serve ads when you mistype an address). Don't you have the same problem if you query your ISP's servers directly? Are you connecting directly to your ISP or on some internal (e.g. enterprise) network? Also try using, (Google) or, (OpenDNS) as the upstream DNS provider instead of your ISP's. Commented Jul 16, 2016 at 17:06
  • If you read linked install guide, you would see I forward all requests to Google DNS, also that ISPs have no control over how my internal DNS works, an ISP cant redirect me to, and Its not a feature I want, its more of a glitch im trying to resolve, hence the question in the first place. (This is all on my home network), I will try re-installing DNSmasq but i may need a more powerfull DNS program after all. Commented Jul 17, 2016 at 17:52

3 Answers 3


The most common reason why you get a bogus IP address for a nonexistent domain is that your ISP converts negative answers into the address of their ad servers, to serve you more ads when you make a typo in the address of a website. This is definitely a shady practice, but unfortunately some ISPs do it.

You can commonly counter that by using different upstream DNS servers, such as OpenDNS (server= and server= or Google (server= and server= If you need your ISP's servers for their own customer services, you can use them only in a specific domain (server=/myisp.com/

This being said, in your case, the problem is that your configuration doesn't do what you want it to do.

How can I stop DNSMasq from resolving non-existent subdomains to a local IP.

By not declaring the domain to be existing. Dnsmasq does not substitute an IP address for non-existent domains.

How can I tell DNSMasq to always use external DNS for a specific entry.

By not declaring a value for that host name, or a wildcard that encompasses that host name.

The problem in your configuration is the line


This is a wildcard: it declares that is the address of home.com and all host names under that domain. You don't want this wildcard, so remove it.

Instead, declare home.com and any individual domain of home.com as host names, not as wildcards, by listing them in /etc/hosts. Remove the no-hosts line — you want to declare specific hosts, so you need it! Or, if you prefer not to use /etc/hosts, keep this line and add a line pointing to a different file declared with addn-hosts=/path/to/hosts-file. Or, if you want to keep it all inside dnsmasq.conf, replace that line by host-record=home.com,

If you want to have a wildcard with exceptions (return for all xxx.home.com except for mymachine.home.com, or always query the upstream servers and substitute only for negative answers), I don't think dnsmasq can do this.


Just to Expand on Gilles correct Answer :

From TheKelleys.org DNSMasq Man-Page

-A, --address=/<domain>/[domain/][<ipaddr>]

Specify an IP address to return for any host in the given domains. Queries in the domains are never forwarded and always replied to with the specified IP address which may be IPv4 or IPv6. To give both IPv4 and IPv6 addresses for a domain, use repeated -A flags. Note that /etc/hosts and DHCP leases override this for individual names. A common use of this is to redirect the entire doubleclick.net domain to some friendly local web server to avoid banner ads. The domain specification works in the same was as for --server, with the additional facility that /#/ matches any domain. Thus --address=/#/ will always return for any query not answered from /etc/hosts or DHCP and not sent to an upstream nameserver by a more specific --server directive. As for --server, one or more domains with no address returns a no-such-domain answer, so --address=/example.com/ is equivalent to --server=/example.com/ and returns NXDOMAIN for example.com and all its subdomains.


Add A, AAAA and PTR records to the DNS. This adds one or more names to the DNS with associated IPv4 (A) and IPv6 (AAAA) records. A name may appear in more than one host-record and therefore be assigned more than one address. Only the first address creates a PTR record linking the address to the name. This is the same rule as is used reading hosts-files. host-record options are considered to be read before host-files, so a name appearing there inhibits PTR-record creation if it appears in hosts-file also. Unlike hosts-files, names are not expanded, even when expand-hosts is in effect. Short and long names may appear in the same host-record, eg. --host-record=laptop,laptop.thekelleys.org,,1234::100 If the time-to-live is given, it overrides the default, which is zero or the value of --local-ttl. The value is a positive integer and gives the time-to-live in seconds.


I had an entry for my domain that was

address=/domain.com/ (my NginX reverse Proxy)

It was causing all non-existent subdomains like acoimasdin.domain.com to resolve to

Since I already have everything set up to forward domain.com to www.domain.com in apache, I made the entry


Now my remote sub-domain DNS gets forwarded on to Google DNS as it should, and non-existent DNS come back as "host doesn't exist" which is exactly what I wanted!

In essence, I can't have a bottom/top (not sure the correct term) level entry that is domain.com or all non-existent DNS entries will use that DNS entry.

  • Oh, I see. You're getting this address only for subdomains of domain.com. You should have mentioned this in your question, it's an important point! But why are you using address if that's not what you mean? address specifies wildcard for the given domain. If you want an address only for the specific host domain.com, then address is not the right option. Write it in a host file. Commented Jul 17, 2016 at 19:47
  • Your question was most definitely not clearly worded. And we expect questions to be self-contained. Always include all relevant information in the question. Don't expect us to go read your blog. Commented Jul 17, 2016 at 20:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .