4

I saw this example of a CNAME record, but I don‘t know what IP would be returned and couldn‘t find an answer.

I‘m looking for the IP of pc2.an.example.com and the mail server of an.example.com

Zone file example.com:

example.com. IN SOA...

example.com. 1800 IN NS ns1.example.com

an.example.com. 1800 IN NS ns1.an.example.com

ns1.example.com. 1800 IN A 12.34.56.78

ns1.an.example.com. 1800 IN A 123.45.67.1

Zone file an.example.com:

an.example.com. IN SOA...

an.example.com. IN NS ns1.an.example.com

ns1.an.example.com. 1800 IN A 123.45.67.1

an.example.com. MX 10 pc2.an.example.com

pc1.an.example.com. 1800 IN A 123.45.67.2

pc2.an.example.com 1800 IN A 23.45.67.89 

pc2 CNAME pc1.an.example.com.

So which IPs would be returned for pc2 and the mail server? My first idea was that the CNAME would be ignored because pc2 has an „A“ record with a full IP, but I noticed there is no dot at the end of pc2.an.example.com, maybe that has an effect because the adress is relative?

Thanks for any help!

Kevin K.
  • 383
  • 1
  • 7
retrok
  • 43
  • 4
  • MX records aren't supposed to point to CNAME records, although I don't think this is enforced widely. – Barmar Jul 17 '18 at 18:38

1 Answers1

6

You'd get:

an.example.com. IN MX 10 pc2.an.example.com

pc2.an.example.com. IN CNAME pc1.an.example.com.
pc1.an.example.com. IN A 123.45.67.2
  • There can't exists another resourse record like A or AAAA with a CNAME. They'd get ignored.

  • pc2.an.example.com without a dot equals pc2.an.example.com.an.example.com. for which the IN A 23.45.67.89 currently is.

Esa Jokinen
  • 43,252
  • 2
  • 75
  • 122
  • Thanks for the answer! Just to clarify, the A record gets ignored and the CNAME record would be used (Got a bit confused with your second point)? – retrok Jul 17 '18 at 16:09
  • 1
    `CNAME` is specified that way: there should not be an `A` record and it can be considered an error, if there is. The name server should only return the `CNAME` and possibly additionally its `A` record. But you happen to not have a conflicting `A` record, because it's missing `.` and is actually something totally else. – Esa Jokinen Jul 17 '18 at 16:26