LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   To get domain name from ip in Reverse DNS Dig (https://www.linuxquestions.org/questions/linux-server-73/to-get-domain-name-from-ip-in-reverse-dns-dig-4175614727/)

luofeiyu 09-29-2017 07:20 AM

To get domain name from ip in Reverse DNS Dig
 
Code:

dig www.ksu.edu.tw +short
120.114.100.101

We get ip address :120.114.100.101 ,whose domain name is www.ksu.edu.tw .
To get domain name from ip in Reverse DNS Dig
Code:

dig -x 120.114.100.101 +short
www.ksu.edu.tw.

We get domain name : www.ksu.edu.tw ,whose ip address is 120.114.100.101.
Code:

dig  smtp.mail.yahoo.com  +short
smtp.mail.global.gm0.yahoodns.net.
106.10.150.171

We get ip address :106.10.150.171 ,whose domain name is smtp.mail.yahoo.com.
Code:

dig  -x 106.10.150.171  +short
vcs-s-myc.mail.vip.sg3.yahoo.com.

why the result is not smtp.mail.yahoo.com as 106.10.150.171's domain name?

MensaWater 09-29-2017 10:49 AM

Mainly because the zone file for reverse IP look ups (ARPA reverse zone) is maintained separately than the zone file for forward lookups.

That is to say when you add a forward lookup (A record, AAAA record or CNAME for this discussion) you are specifying NAMES and telling them which IPs to go to when the name is looked up. On the other hand when you create the separate zone for reverse lookups (PTR records) it is looking up the IP specified and seeing the name in that zone file not in the original forward lookup zone file.

So I could create a forward zone file for example.com with record:
billybob IN A 10.90.70.50

But in my reverse zone file (ARPA) for 10.90.70 I could put a completely different name to resolve to:
50 IN PTR ralph.example.com.

When you did the dig for billybob.example.com it would tell you the IP is 10.90.70.50. But when you did the dig -x for 10.90.70.50 it would tell you the name is ralph.example.com.

I often see people mistakenly putting PTR records in their forward zone files even though nothing would ever look at that file for a reverse (PTR) lookup. Best practice for PTR records is to have only one for each IP even if you have multiple forward records resolving to that IP.

On top of all that is that for your specific example you did a "dig +short" so it only gave you the IP the forward ultimately resolves to. If you had done it without the "+short" it would have shown you that smtp.mail.yahoo.com is actually an alias (CNAME) of smtp.mail.global.gm0.yahoodns.net. So in this case the PTR did in fact give the "real" name associated with the IP - just not the "alias" name that goes to the same IP. But as I said above there is no requirement that it do so.

Some people will reject email from an outbound mail server that does not have a PTR record back to the same name so in cases like that you do want to have the names be the same.

jefro 10-02-2017 08:09 PM

OK, other post flagged.


All times are GMT -5. The time now is 09:36 AM.