How To Fake Dynamic DNS

I have everything I need to keep tabs on my home IP address without signing up for a DDNS service like No-IP or DynDNS. My Synology NAS always knows its address when it’s online, and because it’s essentially a little Linux box, there’s no reason it can’t tell my other sites where to find it.

In my case, I want to be able to reach my home IP address by visiting a certain URL on either my remote Linux or Windows host — something like But I don’t really want to hide the IP address like a real DDNS would, and I don’t think my hosting providers would even accommodate that. So I rolled my own.

On the remote web host, I created a few PHP files to receive the notifications. common.php does most of the work:

My index page calls redirect(), which reads in the IP address and sends the visitor to it if it’s valid. There’s another page that calls setIp(), and that’s the page that my home computer is going to call, passing in the “password” at the top.

I used putty to log into the Synology server and stopped the cron job.

/usr/syno/etc/rc.d/ stop

Then I edited  /etc/crontab to call a shell script in admin’s home directory every few hours. Don’t copy/paste this into the file using putty, but rather type it in directly and use only one tab to separate each column. Typing it directly prevents special (invisible) characters from getting into the file, which could cause it to be overwritten by the default file upon reboot.

*       */4     *       *       *       root   /volume1/homes/admin/cron/

In the shell script, I used wget to make the web request. curl would work just as well. I could have just added this command to the crontab file, but it’s easier to manage a shell script in the home directory. I can also extend it more easily at a later date. The shell script simply contains:

/usr/syno/bin/wget --tries=2 "" -O -

The Synology DiskStation makes a working copy of the crontab when it starts up, and stores it in /var/spool/cron/crontabs/root, so to be safe I just rebooted the device rather than just starting the service up again. When I started the service using “ start”, it would work only until the DiskStation rebooted, and after that it would default back to the original. Rebooting the device right away seems to have fixed that problem.

Tags: , ,


Your email address will not be published. Required fields are marked *