atipugin
By:
atipugin

How to configure Bind9 to work with wildcard domains?

March 15, 2015 4.8k views
DNS Ubuntu

My app allows users to use own domains for their profiles. They should be able to delegate their domains to my ns servers (i.e. ns1.mynsdomain.com, ns2.mynsdomain.com).

So i decided to try Bind9 as a DNS server, but can't figure out how to configure it properly to work with wildcard domains.

Things i did:

  1. Added zone:
zone "." {
    type master;
    file "db.wild";
};
  1. Added db.wild file with following content:
$TTL    86400
@   IN  SOA  mynsdomain.com. root.mynsdomain.com. (
             100500     ; Serial
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
              86400 )   ; Negative Cache TTL

    IN  NS  ns1.mynsdomain.com.
    IN  NS  ns2.mynsdomain.com.
    IN  A   MY_SERVER_IP_ADDRESS

ns1 IN  A   MY_SERVER_IP_ADDRESS
ns2 IN  A   MY_SERVER_IP_ADDRESS

*.  IN  A   MY_SERVER_IP_ADDRESS

Now if i try to ping example.com (which is already delegated to ns1.mynsdomain.com./ns2.mynsdomain.com.), it responds with "cannot resolve example.com: Unknown host"

What's wrong with my setup?

4 Answers

Hi,

Remove the A record, and make it a CNAME

*. MYDOMAIN. IN CNAME MYDOMAIN.

Mind the dots at the end of the MYDOMAIN

Remove the dot and change A to CNAME

*  IN  CNAME   MY_SERVER_IP_ADDRESS

Thanks guys, now it seems to work. But there is one weird thing - example.com and www.example.com works fine, but any other subdomain (i.e. app.example.com) don't. Any suggestions?

What do you mean, doesn't work?

You will need a *. mydomain.com in your virual hosts conf as well.

Or add the subdomains you want to use there.

https://achtig.nl

Wildcard ssl, dns and virtual hosts.....

Have another answer? Share your knowledge.