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...?

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!

thanks dude :) appreciate it

thanks dude :) appreciate it

Glad could help.. :)

Hi,

gethostbyname() example

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

echo $ip;
?>

gethostbyaddr() example

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

echo $hostname;
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.