Free DynDns (Sort Of)

So I wanted to access my home network from outside. My ISP doesn’t hand out static IPs and DynDns doesn’t work on my router / also i don’t want to pay for it anyhow.

Solution:

All I really want is my IP address. This can be displayed from sites like whatismyip.com very easily. We’ll do it like they do and store the result somewhere on the web. There are plenty of free webhosts that support PHP. I set up a tiny website to set and get the IP address of my home gateway.

The website basically contains 2 webpages and 1 file. One webpage is called by my home server every hour, this page collects the IP address from the calling home server and writes it to a file on the webserver.

set.php :=


#get caller's ip address, we will have to pwd protect access to this file yes? $ip_address = $_SERVER['REMOTE_ADDR']; 
$file = fopen("ipfile", "w+"); 
if( $file==false) 

   echo("error opening filen");
   exit(); 

fwrite($file, $ip_address); 
fclose($file); 
?>

The powershell script to call it was a bit of a pain to write as powershell is very fussy when it comes to authentication and signing scripts. Probably should have just used wget for windows, but I wanted to try something new.

PowershellScript.ps1 := 

$client = New-Object System.Net.WebClient; 

$client.Credentials = New-Object System.Net.NetworkCredential("usernamehere","passwordhere"); 

$client.DownloadData('http://mywebsite.domain.com/set.php'); 

I just used basic http authentication. Don’t want anyone becoming curious as to what the IP address is for if they stumble accross it, and more importantly I don’t want them running my set.php page and overwriting my IP with their own!

For getting the IP address I use the get.php page :=

$file = fopen("ipfile", "r"); 
if( $file==false) 

   echo("error opening filen");
   exit(); 

$filetext = fgets($file, 100);
fclose($file);

then in the body display IP address:

(Very difficult to put all this php code into blogger blogpost, stuff keeps disappearing!)
I give up trying to write code here now.
Gonna set up my server for incoming connections now. Just wanna access my music and videos from my android.

One thought on “Free DynDns (Sort Of)

Comments are closed.