← Back to challenges

Find Domain Name From DNS Pointer (PTR) Records Using IP Address

PythonHardformattinglanguage_fundamentals

Instructions

Write a function that takes an IP address and returns the domain name using PTR DNS records.

Example

get_domain("8.8.8.8") ➞ "dns.google"

get_domain("8.8.4.4") ➞ "dns.google"

Notes

  • You may want to import socket.
  • Don't cheat and just print the domain name, you need to make a real DNS request.
  • Return as a string.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.