954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

find host IP

hi

Ive been posed this problem. A friend does maintenance on a companies network, and would like to do it remotely. Currently, their IP changes every 24hrs and so he has to phone them to find their IP so that he can log in...

He asked me to write him something which would pull the host's IP and email it to him, probably running as a cron job...

I can retrieve a visitors IP using PHP, but have no idea how to get the hosts IP...?

lifeworks
Junior Poster
145 posts since Nov 2007
Reputation Points: 15
Solved Threads: 2
 

hi

Ive been posed this problem. A friend does maintenance on a companies network, and would like to do it remotely. Currently, their IP changes every 24hrs and so he has to phone them to find their IP so that he can log in...

He asked me to write him something which would pull the host's IP and email it to him, probably running as a cron job...

I can retrieve a visitors IP using PHP, but have no idea how to get the hosts IP...?

I dont have any experience working with cron jobs but to retrieve the host's ip address u can use--

$_SERVER['SERVER_ADDR']


.
Send its value through cron job and ur problem is solved...
cheers!

venkat0904
Junior Poster
190 posts since Oct 2009
Reputation Points: 13
Solved Threads: 21
 

thanks dude :) appreciate it

lifeworks
Junior Poster
145 posts since Nov 2007
Reputation Points: 15
Solved Threads: 2
 
thanks dude :) appreciate it


Glad could help.. :)

venkat0904
Junior Poster
190 posts since Oct 2009
Reputation Points: 13
Solved Threads: 21
 

Hi,

gethostbyname() example

<?php
$ip = gethostbyname('www.example.com');

echo $ip;
?>


gethostbyaddr() example

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

echo $hostname;
?>
monica singh
Light Poster
48 posts since Oct 2010
Reputation Points: 11
Solved Threads: 10
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: