Implement your own free DNS service.
If you want to access your home computer, Raspberry Pi or other networked devices you may be familiar with dynamic DNS services. These allow you to find your home network from anywhere in the world using the internet.
These services are ok and used to be free, but now cost money.If you have a web page that you pay for or even a webpage that you ISP provides, if it supports PHP, you can implmenent your own dynamic DNS like service.
In order to do this you need the following PHP code in a .php file on your server:
<?php
$pass=$_GET['pass'];
if($pass=="password")
{
$ip = $_SERVER['REMOTE_ADDR'];
$write_file = fopen("local_ip_address.txt","w");
echo $ip;
fwrite($write_file, $ip);
fclose($write_file);
}
?>
The file needs to be made publicly executable, this is why the password is required, it would also be advisable to keep the file hidden if it is on a public facing site.
When the PHP code is called the address of the caller is recorded in the text file "local_ip_address.txt", which you can then access from other pages or scripts.
You can change "password" and "local_ip_address.txt" to your preferred values.
On the next page we'll show you how to call the code using various methods.