4

Let's suppose i have a domain which DNS contains 2 records:

  • a "A" record which contains an IP Address
  • a "CNAME" record which contains another domain (alias). Let's suppose this domain contains an IP to a second IP Address

My question is: Which one of the 2 IP Addresses will be answered if i ask a DNS resolution of my domain ?

Thanks

Bob5421
  • 319
  • 3
  • 8
  • 16
  • 1
    Does this answer your question? [Why can't a CNAME record be used at the apex (aka root) of a domain?](https://serverfault.com/questions/613829/why-cant-a-cname-record-be-used-at-the-apex-aka-root-of-a-domain) – Bob Jan 14 '21 at 10:03
  • 1
    Although primarily concern with the apex the point is that standards don’t allow a CnAME to coexist with other records – Bob Jan 14 '21 at 10:04

2 Answers2

1

Let's assume you have a server at IP address 111.111.111.111. You also have a domain called example.com. You can create an A record for example.com to point to 111.111.111.111.

The format that is used for a CNAME is [name] is an alias of [target].

So if you create a CNAME name: www.example.com to a target: example.com then www.example.com will do a redirect call for example.com, which will resolve to the IP address of 111.111.111.111.

CNAME resolves to A record

So basically when you create a CNAME you do not set another IP address, so you will only have one (the original A record) IP address to resolve to.

Original source of image: https://www.keycdn.com/support/what-is-a-cname-record

Barnabas Busa
  • 772
  • 6
  • 10
  • 1
    No in fact i want to know what happens if cname is targeting another domain and if this other domain contains a « A » field with a 222.222.222.222 ip for example – Bob5421 Jan 14 '21 at 10:33
  • If you try to add the same CNAME to a different host you will get an error message such as: "An A, AAAA, or CNAME record with that host already exists. (Code: 81053)" – Barnabas Busa Jan 14 '21 at 10:42
1

You cannot have a CNAME record and other records for the same name.
If the scenario in the question is that you would have a CNAME record and an A record side by side, that is not really a concern since it is not possible.

Håkan Lindqvist
  • 35,011
  • 5
  • 69
  • 94