Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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? Thanks.

share|improve this question

3 Answers 3

up vote 9 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.

share|improve this answer
    
Works fine, but the main domain doesn't get resolved ? Any ideeas ? eg : testdomain.com –  opc0de Jan 7 at 20:59

According to the dnsmasq man page

address=/#/1.2.3.4

should do the trick.

share|improve this answer
    
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

You can do wildcard matching in bind.

*.domain.com.        IN      A       a.b.c.d

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.

share|improve this answer
1  
What part of "all domains" did you miss? –  ceejayoz Jun 8 '12 at 18:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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