Configure DNS server to return same IP for all domains

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?


Solution 1:

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.

Solution 2:

According to the dnsmasq man page

address=/#/1.2.3.4

should do the trick.

Solution 3:

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.

Solution 4:

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.