Reverse DNS

From ScriptsPedia

Jump to: navigation, search

Get the Internet host name corresponding to a given IP address. See an example for a reverse dns lookup to see the result of such tests.

PHP

PHP has a built-in function called "gethostbyaddr()" to get the hostname corresponding to a given IP address. This example demonstrates a simple usage of this reverse DNS function.

<?php
   echo gethostbyaddr($_SERVER['REMOTE_ADDR']);
?>

Python

To retrieve the domain name pointer of an IP address, you can use python's "socket.gethostbyaddr()".

import socket;
   socket.gethostbyaddr();
Personal tools