I would like to configure a nameserver that will return the same IP address ("A" record) for any arbitrary host name. For example:

  • example.com
  • subdomain.example.com
  • someotherdomain.com
  • anyotherdomain.co.uk

should all return the same IP address. Is there a way to do this with BIND? Or is there an alternative to BIND that can do this?

up vote 16 down vote accepted

With BIND, you need a fake root zone to do this. In named.conf, put the following:

zone "." {
    type master;
    file "/etc/bind/db.fakeroot";
};

Then, in that db.fakeroot file, you will need something like the following:

@ IN SOA ns.domain.com. hostmaster.domain.com. ( 1 3h 1h 1w 1d )
  IN NS <ip>
* IN A <ip>

With that configuration, BIND will return the same IP address for all A queries.

  • Works fine, but the main domain doesn't get resolved ? Any ideeas ? eg : testdomain.com – opc0de Jan 7 '14 at 20:59
  • This works pretty darned well. The only issue is NS record queries for the domain might explode - namely that it serves the NS records for the . zone, which won't respond for any given domain's NS queries. (But it otherwise works to serve the proper A record) – Thomas Ward Oct 3 '17 at 18:18

According to the dnsmasq man page

address=/#/1.2.3.4

should do the trick.

  • Thanks! That was so simple. Dnsmasq is definitely easier to configure than BIND. – balexand Jun 8 '12 at 16:09
  • Do you know if there's also a way to use a wildcard with MX records in dnsmasq? – balexand Jun 14 '12 at 18:15
  • It looks like mx-host and mx-target will do this. – Gerald Combs Jun 14 '12 at 18:49
  • 1
    Do you know how? The use of wildcards with mx-host and mx-target is not documented in the man page and I can't get it to work. I've tried using similar notation to the address option(# sign). I've been able to get wildcards working with both A and MX using BIND using Oliver's suggestion, but I'd actually prefer to use dnsmasq. Thanks! – balexand Jun 15 '12 at 22:55
  • dnsmasq is more of a recursive nameserver than an authoritative one (could be used parly like that, but clearly not its main goal) – Patrick Mevzek Aug 9 at 20:46

You can do wildcard matching in bind.

*.example.com.        IN      A       192.0.2.45

This has to be defined in your named configuration file for the domain. Just be carefull if you need to define other A records for the domain.

  • 3
    What part of "all domains" did you miss? – ceejayoz Jun 8 '12 at 18:29

You can also use the tool fakedns. The usage is very simple - it will bind to post 53 UDP and serve the same IP to all A queries. You provide the IP address as a command line parameter. By far the easiest solution. Requires Python to run.

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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