Let's say I'm trying to lookup the IPs mail.yahoo.com, gmail.com and mail.google.com
If I execute:
dig @8.8.8.8 +nocomments +noquestion \ +noauthority +noadditional +nostats +nocmd \ gmail.com mail.yahoo.com mail.google.com I get:
gmail.com. 299 IN A 173.194.123.21 gmail.com. 299 IN A 173.194.123.22 mail.yahoo.com. 0 IN CNAME login.yahoo.com. login.yahoo.com. 0 IN CNAME ats.login.lgg1.b.yahoo.com. ats.login.lgg1.b.yahoo.com. 0 IN CNAME ats.member.g02.yahoodns.net. ats.member.g02.yahoodns.net. 0 IN CNAME any-ats.member.a02.yahoodns.net. any-ats.member.a02.yahoodns.net. 17 IN A 98.139.21.169 mail.google.com. 0 IN CNAME googlemail.l.google.com. googlemail.l.google.com. 243 IN A 173.194.123.21 googlemail.l.google.com. 243 IN A 173.194.123.22 Can I ensure that if I see a CNAME record, the A record corresponding to it won't appear before a CNAME corresponding to another machine or an A record for other hostname?
For instance, let me focus on mail.yahoo.com (I just want the IP or IPs mail.yahoo.com resolves to):
This is the output:
mail.yahoo.com. 0 IN CNAME login.yahoo.com. login.yahoo.com. 0 IN CNAME ats.login.lgg1.b.yahoo.com. ats.login.lgg1.b.yahoo.com. 0 IN CNAME ats.member.g02.yahoodns.net. ats.member.g02.yahoodns.net. 0 IN CNAME any-ats.member.a02.yahoodns.net. any-ats.member.a02.yahoodns.net. 17 IN A 98.139.21.169 The hostname I'm looking for ( mail.yahoo.com) is the first column of the first entry. Then there's a bunch of CNAMES I really don't care about, and then an A record with the actual IP (which I do care about).
Is there a possibility of getting the CNAMES or A records out of order? Something like:
ats.login.lgg1.b.yahoo.com. 0 IN CNAME ats.member.g02.yahoodns.net. #(!)BAD ats.member.g02.yahoodns.net. 0 IN CNAME any-ats.member.a02.yahoodns.net. #(!)BAD mail.yahoo.com. 0 IN CNAME login.yahoo.com. login.yahoo.com. 0 IN CNAME ats.login.lgg1.b.yahoo.com. any-ats.member.a02.yahoodns.net. 17 IN A 98.139.21.169 Or even worse (the actual A record on top):
any-ats.member.a02.yahoodns.net. 17 IN A 98.139.21.169 mail.yahoo.com. 0 IN CNAME login.yahoo.com. login.yahoo.com. 0 IN CNAME ats.login.lgg1.b.yahoo.com. ats.login.lgg1.b.yahoo.com. 0 IN CNAME ats.member.g02.yahoodns.net. ats.member.g02.yahoodns.net. 0 IN CNAME any-ats.member.a02.yahoodns.net. Or the worse of the worse (in a multi-resolution dig execution, as the one shown on top of the post):
ats.member.g02.yahoodns.net. 0 IN CNAME any-ats.member.a02.yahoodns.net. any-ats.member.a02.yahoodns.net. 17 IN A 98.139.21.169 mail.google.com. 0 IN CNAME googlemail.l.google.com. # This one I want gmail.com. 299 IN A 173.194.123.21 # This one I want gmail.com. 299 IN A 173.194.123.22 # This one I want mail.yahoo.com. 0 IN CNAME login.yahoo.com. # This one I want login.yahoo.com. 0 IN CNAME ats.login.lgg1.b.yahoo.com. ats.login.lgg1.b.yahoo.com. 0 IN CNAME ats.member.g02.yahoodns.net. googlemail.l.google.com. 243 IN A 173.194.123.21 googlemail.l.google.com. 243 IN A 173.194.123.22