0 Replies - 509 Views - Last Post: 02 December 2011 - 02:50 PM Rate Topic: -----

#1 SpiderSpartan  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 14
  • View blog
  • Posts: 120
  • Joined: 06-February 08

need to get the ip address of a device by hostname or mac address

Posted 02 December 2011 - 02:50 PM

I'm trying to get the IP address of a wifi thermostat on my local network. I've tried to do so using gethostbyname(), but it returns a strange external looking IP.

My DHCP client list shows the thermostat info as follows:
Host Name - thermostat-55-C5-AE, IP Address -, MAC Address - 5CDAD455C5AE010000.

Below is the code I've got so far. The gethostbyname() function returns some external address that doesn't make any sense. The gethostbyaddr() function returns the same ip address input to it. Does anyone have any idea how to do this? If anyone knows how to do this with javascripting I could do it that way too. Thanks in advance for any help.

$hostname = 'http://thermostat-55-C5-AE.com';	#'SPIDER-SERVER';	#'thermostat-55-C5-AE';
echo 'Getting IP for '.$hostname.'<br>';
$ip = gethostbyname($hostname);	#'www.example.com');

echo $ip.'<br><br>';

$addr = '';
echo 'Getting hostname for '.$addr.'<br>';
$hostname = gethostbyaddr($addr);

echo $hostname;

Is This A Good Question/Topic? 0
  • +

Page 1 of 1