Report this

What is the reason for this report?

How to configure Bind9 to work with wildcard domains?

Posted on March 15, 2015

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?



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!

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.

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

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…

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.