PDA

View Full Version : PHP server IP script



The Titan
February 11th, 2008, 12:13 PM
Im just going to start from the beginning for this one ;)

Ok, I have a domain name hosted by a 3d party. I also have a sorry home server that as a use as a testing environment, The problem is i have a dynamic IP.

Is it possible to make a script (cron job maybe?) that gets my ip from the internet and send it to the domain with a form? I can do any scripting in PHP or do forms but i dont know how to get my server IP.

If this is confusing, or you need more information please tell me.

Thank you,
-Dan

bobbocanfly
February 11th, 2008, 12:33 PM
You could try


$_server['server_ADDR'];

The Titan
February 11th, 2008, 12:38 PM
Thank you for that, How would i go about running that PHP script every 5 minutes? Could i use a CronJob? I've never used them before.

-Dan

bobbocanfly
February 11th, 2008, 01:35 PM
Thank you for that, How would i go about running that PHP script every 5 minutes? Could i use a CronJob? I've never used them before.

-Dan

I have never used PHP-CLI before but my guess is yeah you could use it as a cronjob. Im pretty sure there is a tutorial around here that tells you exactly what to do.

bsharp
February 13th, 2008, 02:27 AM
...or you could use dynamic DNS which would accomplish the same thing and probably be easier to set up

miked595
March 2nd, 2008, 05:44 PM
Yea dynamic dns would work better. I have these script on my site that work on ubuntu.

http://www.xpertdns.com/wiki/index.php/IpTeller
http://www.xpertdns.com/wiki/index.php/Java_Apps:DynamicDNSclient

The Titan
March 2nd, 2008, 05:56 PM
Thank you for the replies, like bobbocanfly said there was a tutorial with exactly what i needed as far as the cronjob goes and i got it all set up.

-Dan

raj_arjun
July 17th, 2009, 01:14 PM
OK.. well this script workson ma local system and gives me its ip correctly

hope it ll help :P


<?php


$last_line = exec("/sbin/ifconfig", $op);

$line = $op[1];
$peices = explode(" ",trim($line));
$ips = explode(":",trim($peices[1]));
$system_ip = trim($ips[1]);

?>

curvedinfinity
July 17th, 2009, 03:01 PM
Some home routers have ddns built in. You just have to tell the router your login info and it will keep your dynamic domain's host up to date with your IP.

I know Rosewill and D-Link routers come with this.

Here's the biggest ddns provider:
http://www.dyndns.com/

Its a free service for a subdomain.