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 newbie question about DNS records.

I have one server which I'm hosting a handful of sites on. Currently, each site has it's domain hosted by an independent provider and each has an A record pointing to the server's IP address.

But if I want to change the server in the future, I will have to go back an update each IP address in each DNS record.

Is it possible to use a CNAME record on each domain to point to another domain that I control directly? This is so I can update the IP address in 1 place myself and not have to get all these other DNS providers to update their records separately?

Sorry if this is a duplicate question but I couldn't seem to find one that answers this problem directly in a way I understand.

Thanks

share|improve this question
    
Excellent question –  Marco Demaio Feb 21 '13 at 20:23

4 Answers 4

up vote 5 down vote accepted

That's exactly the point of a CNAME. A CNAME does not need to point to a DNS in the same zone, it can point to any DNS name registered with any nameserver.

What it means for your clients is an additional DNS lookup on the NS for the other host, but that's a tiny price to pay for the majority of websites on the internet.

share|improve this answer

Per Farseeker's answer, yes, this is what CNAME records are for.

However whilst you can use this to point www.example.net to www.example.com, you can't use it to point example.net on its own (i.e. without the www prefix) to something else.

This is because example.net must also have an SOA record and NS records, and it's not legal in DNS to have a CNAME present at the same part of the tree as any other records (DNSSEC keys excepted)

share|improve this answer
1  
"example.net must also have an SOA record". Some people cheat: look at lrnskls.com. –  bortzmeyer Sep 16 '09 at 8:00
    
it's a nasty hack, and they'll have a huge problem should they ever want to DNSSEC sign it. –  Alnitak Sep 16 '09 at 10:07
2  
+1 this is a good point and one of the bigger flaws (and reason why none of my sites can be used www-less as those domains also needs an MX record, prohibiting this). –  Oskar Duveborn Sep 16 '09 at 12:08

Yes it is possible.

That's how I do my experimental web servers that also have dynamic IPs (though seldom changed).

share|improve this answer

I will have to go back an update each IP address in each DNS record.

Well, CNAMEs are indeed a possible solution (see Alnitak's reply for a limit of the CNAMEs) but there is another one: instead of managing your zone files by hand, create a ten-lines program (Perl / Python / Ruby / cpp / m4 / whatever) which will generate the zone files from a master (a text file, a XML file, a DBMS, whatever)

That way, your IP address can be in only one place. When it changes, just re-run the program.

share|improve this answer

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.