Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

What is the difference between a CNAME and a Subdomain?

I understand that the a cname (the left side of a domain) can point to the domain, so you can two different urls point to the same address, ie.

ex1.mydomain.com - if setup as a CNAME can return the IP of mydomain.com

If ex1.mydomain.com is setup as a subdomain, does it have a different IP?

Another question is what should the ideal setup be in this situation:

I have IP1:80 for a web app

I have IP2:80 for another app

Can I point both of these IPs to the same A record, with perhaps a different cname or subdomain?

Thanks for any help?

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

A CNAME is a type of DNS record, where a hostname points at another hostname.

An A record is another type of DNS record, where a hostname points at an IP address.

A subdomain is what you described as 'the left side of the domain', e.g. webmasters.stackexchange.com is a subdomain of stackexchange.com. The DNS setup for a subdomain could use either an A record or a CNAME.

Your question:

Can I point both of these IPs to the same A record, with perhaps a different cname or subdomain?

Doesn't really make sense. You don't point IPs at A records, you point hostnames at IPs using A records. If you're asking if you could point a domain and a subdomain at the same IP, the answer is yes.

This might be clearer with a real world example:

webmasters.stackexchange.com has an A record that points to the IP 198.252.206.140. stackexchange.com also has an A record that points to the IP 198.252.206.140.

It would therefore be possible to change webmasters.stackexchange.com to CNAME to stackexchange.com, and everything would continue to work as it does now.

(In practice, CNAMES are slightly slower than A records as they might result in an additional DNS lookup, so that's one reason why A records are more commonly used.)

share|improve this answer
    
Thanks for the awesome answer! I had originally asked this question in stackoverflow, and when I was moving it over here, it got answered there as well. My solution is going to be to use two two different A records, one as a subdomain, so I can use the same domain. IE - ex1.mydomain.com (IP1) and mydomain.com (IP2) –  Greg Gamm Apr 1 at 17:57
add comment

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.