Share via


Can i point multiple a records to a cname record

Question

Friday, December 9, 2011 8:32 AM

Hi,

can i point multiple A records to a particular CNAME records. Like if we create have two web server for failover and each will have its own A records In DNS. Now if I create a CNAME record like web.abc.com. Now can i point this CNAME record to two different webserver so if my one server will down the request will redirected to other server.

Thanks

Raju

All replies (1)

Friday, December 9, 2011 4:19 PM âś…Answered

can i point multiple A records to a particular CNAME records. Like if we create have two web server for failover and each will have its own A records In DNS. Now if I create a CNAME record like web.abc.com. Now can i point this CNAME record to two different webserver so if my one server will down the request will redirected to other server.

First of all... an "A" record can't point to a "CNAME" while the opposite is true; a "CNAME" can point to a given "A" record; that said, and keeping in mind that you can't have two "CNAME" records with the same name, if your purpose is to point your "www" to multiple IP addresses, it can be done just by adding multiple "A" records with the same name

To make an example, let's say you own the domain called "example.com" and the whole 192.0.2.0/24 netblock; now, let's suppose, just for this example that you published three webservers sitting at 192.0.2.1, 192.0.2.2 and 192.0.2.3 and that you want any of them to be reachable just by entering www.example.com in the browser address bar; in such a case, you may modify your DNS zone as follows

 

www  IN A  192.0.2.1
www  IN A  192.0.2.2
www  IN A  192.0.2.3

 

and then, optionally, enable the "DNS round robin" feature; this way requests for "www.example.com" will be spread amongst the various servers; notice though that such an approach won't give you real fault tolerance nor real load balancing; the first won't work since if (say) 192.0.2.2 is offline and, by chance, the client requesting "www" gets that IP as the first one, the request will fail; the second since while the requests will be spread around the various IPs (given that round robin is enabled and the A record have a low TTL), there won't be any real "load monitoring and balancing" taking place and, by the way, nothing forces a given client to select the first returned IP (even if that's what usually happens)

Getting back to your CNAME, if you insist in using CNAME, you may do that this way

www  IN CNAME web.example.com

web  IN A     192.0.2.1
web  IN A     192.0.2.2
web  IN A     192.0.2.3

but sincerely I can't see any reason to use such an approach in place of the previous one, also because using the CNAME will cause an additional rountrip to the DNS server to retrieve the A record(s) pointed by the CNAME

HTH