Track your Dynamic IP



For several reasons I’d like to keep my dynamic IP instead of install a static IP, but I had to use a service such as, etc. The only thing I was needed was just the current IP of my home router. So, I had this simple idea which when the linux box detects an IP change, then the script updates the web page. So, when I want to get informed about the ip of my home router, I’m visiting the address For this, I made a php script which runs nicely.

Initially, we need a linux box (I’m using a VM) and a hosting plan somewhere over the Internet.

So, we have to install two scripts. The first one at the web site, and the other to my linux box.

Linux box php script:

$current_ip = file_get_contents('');
$stored_ip = file_get_contents('');
$current_ip = substr($current_ip, 0, -1);
$pos = strpos($current_ip, $stored_ip);
if($pos !== 0)

web site script:

$fp = fopen('data.txt', 'w');
fwrite($fp, "$_GET[ip]");
$filename = "data.txt";
$handle = fopen($filename, "r");
$contents = fread($handle, filesize($filename));
echo $contents;

Finally,  put the linux script in a crontab  job running every 5 mins and you’re done!

Now, if you’ll visit your web site you’ll get the ip of your home router.So simple!

enjoy it!