Question

How to configure Bind9 to work with wildcard domains?

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?

Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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…

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?

Remove the dot and change A to CNAME

*  IN  CNAME   MY_SERVER_IP_ADDRESS