Search code examples
dnsnslookupdig

No way to get a domain name from IP address based on A record?


dig redhat.com
;; QUESTION SECTION:
;redhat.com.            IN  A

;; ANSWER SECTION:
redhat.com.     3600    IN  A   209.132.183.105

We get the ip address 209.132.183.105----the A record of domain redhat.com.
Now i want to get the domain name from the ip--209.132.183.105.
Maybe you introduce two ways to get it.

nslookup  209.132.183.105
Server:     192.168.1.1
Address:    192.168.1.1#53

Non-authoritative answer:
105.183.132.209.in-addr.arpa    name = redirect.redhat.com.

Authoritative answers can be found from:


dig -x 209.132.183.105
; <<>> DiG 9.9.5-9+deb8u7-Debian <<>> -x 209.132.183.105
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 62599
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1280
;; QUESTION SECTION:
;105.183.132.209.in-addr.arpa.  IN  PTR

;; ANSWER SECTION:
105.183.132.209.in-addr.arpa. 519 IN    PTR redirect.redhat.com.

;; Query time: 1 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Sat Nov 19 15:11:33 CST 2016
;; MSG SIZE  rcvd: 90

It is unlucky taht the result is not redhat.com and redirect.redhat.com is a PTR record with 209.132.183.105.
Could i draw a conclusion that no way to get a domain name from the IP address in condition of that the ip is A record of domain name?


Solution

  • You are correct in that there is no way to get the info reliably.

    Anyone who owns a domain name can point any A, AAAA or CNAME to whatever IP address they like irrespective if they control that IP address.

    It gets even more complex in that if you have the reverse delegation set up for your IP address(es) you can set whatever PTR record you like - even stuff that's invalid or none existent.

    If you owned the domain rubber-chickens.com there is nothing stopping you creating the following;

    google.rubber-chickens.com A 216.58.210.36 - Which points to google or
    200.200.120.11 PTR msn.microsoft.com. - Which when you did a traceroute or dig would appear to show the hostname msn.microsoft.com

    IP's and domains are just made up in this example.