0

$ host 64.34.119.12 12.119.34.64.in-addr.arpa domain name pointer stackoverflow.com.

How is this Carried out in php? I am planning to do lookup for searching Google's ip. How do i do implement this?

Like in above example it is stalkoverflow.com

I want to determine their netblock and do strstr on their netblock for "google"

if it is matched, it will , echo "Yeah , its google"

Fred Glenn
  • 29
  • 1
  • 3
  • Look at the related section, to the right. – Aurimas Ličkus May 01 '12 at 08:22
  • Note that other people may identify themselves as Google as well (it's just a DNS post after all), and that Google very well may identify themselves as something else from time to time to catch people trying to trick their system. – Emil Vikström May 01 '12 at 08:44
  • Yeah, but most of time. Reverse and forward lookup will reveal that. OR Simple Whois Lookup. – Fred Glenn May 01 '12 at 08:50

1 Answers1

3

Your looking for gethostbyaddr(string ip_address), see: http://php.net/manual/en/function.gethostbyaddr.php

Example:

<?php
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);

echo $hostname;
?>
Tom Hallam
  • 1,924
  • 16
  • 24