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

I have a domain, with a number of CNAME records to

www.mydomain.com mail.mydomain.com ftp.mydomain.com

Now, what I would like to achieve is that if any other subdomain is queried or the domain itself is queried, I would like to have www.mydomain.com returned such that if

mydomain.com or inexistent.mydomain.com are queried, www.mydomain.com is returned by default.

I am not sure how this is possible if it is? Any help is appreciated.

John

share|improve this question
add comment

1 Answer

for inexistent.mydomain.com just add

*.mydomain.com. CNAME www.mydomain.com.

But you can't CNAME mydomain.com as it's root of your zone. See here: http://stackoverflow.com/questions/655235/is-root-domain-cname-to-other-domain-allowed-by-dns-rfc

But you can create A record for mydomain.com, and have *.mydomain.com. CNAME mydomain.com.. In this case everything that ends with .mydomain.com would resolve to same ip.

share|improve this answer
2  
Although, I'd recommend setting up the A record instead of the CNAME. e.g. *.example.com IN A 127.0.0.1 It reduces the number of lookups made to the DNS server. –  frogstarr78 Oct 22 '11 at 16:05
    
I am aware of that but I guess there's no other option since I am using a multi-site on a single IP setup using Apache VirtualHosts. –  John Oct 22 '11 at 16:52
2  
@John But what has a CNAME to do with Apache's VirtualHosts? Or better: Who told you that they only work with CNAMEs? –  mailq Oct 22 '11 at 17:08
    
Can't get this done on godaddy... There's a limit of number of records in my zone file. But a wildcard record should count just as one no? –  John Oct 22 '11 at 17:13
1  
A CNAME and an A record will work exactly the same with respect to virtual hosts. The client will still follow the DNS to decide what address to connect to and will still set the host header to the original host it was looking for. –  David Schwartz Oct 22 '11 at 18:45
show 2 more comments

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.