Case Study - Global Reach, Local Touch: The Role of GeoDNS in eCommerce Expansion

Dynamic DNS scripts for Linux

If you have reached this point to set up your Dynamic DNS scripts, then we suppose you have already created your DNS zone and A records as well. If not, please take a look at our previous article Getting Started with Dynamic DNS for more information regarding this matter.

How to download the scripts?

The scripts can be downloaded from the Dynamic URL pop-up of your A record. For Linux you can use Perl, PHP, or Python, depending on your personal preferences.

How to use the Perl script?

First, you should see if you already have Perl installed on your device. You could check if Perl is already installed and what version do you use with the following command typed in your Terminal:

$ perl --version

Before using the Perl script, you need to download it. To do so, from your Dynamic URL window, click on the Perl script download link and save it on your computer.

Now you need to configure a cronjob to open your Perl script regularly. Open Terminal (or press Ctrl + Alt + T) and type the following command:

$ crontab -e

This will open your user's crontab. If it asks you to choose between several text editors, we recommend you to choose Nano and hit Enter. The crontab will open and you will be able to add a cron job for that script. Add the following line for an every-5-minutes interval:

*/5 * * * * perl /path/to/script

The example above is just an sample. Instead, you should set the correct path for your script. Here is a real-live example:

*/5 * * * * perl /home/Vladimir/Downloads/dynamic-url-perl.pl

Save the crontab with Ctrl+X, press the Y button on your keyboard to save the changes, and then Enter. And this is pretty much the whole set up for using the Dynamic DNS script with Perl.

How to use the Python script?

As you can guess, you must have Python installed on your side in order to use the Python script. To check if you have Python installed and what version do you use, execute the following command in your Terminal:

$ python --version

Similarly to the Perl script, you must download the Python script first. Once downloaded, run Terminal (or press Ctrl + Alt + T) and type the following command to open your user’s crontab:

$ crontab -e

If you want your cronjob to run your Python script on every 5 minutes, set the following parameters:

*/5 * * * * python /home/Vladimir/Downloads/dynamic-url-python.py

Save the file, and that is it.

Note: Do not forget to use your actual path to your script.

How to use the PHP script?

The steps are almost the same. First, check if PHP is already installed by running the following command:

$ php –version

Afterward, download the PHP script from the Dynamic URL window and save it on your computer. Run the Terminal (Ctrl + Alt + T) and open your cron’s tab with the following command:

$ crontab -e

Type the following parameters to set up your cron job to run the script in every 5 minutes:

*/5 * * * * php /home/Vladimir/Downloads/dynamic-url-php.php

And that’s all. Easy, isn't it?

Note: We would like to remind you one more time, you should set the actual path to your script.

How does it work?

Let imagine your public IP has just been changed. When you run the script, it will “open” the relevant Dynamic URL for your record, and the A record will be updated with your new IP address.

As for the cronjob, it just executes your script repetitively and regularly. That's the whole magic.


Last modified: 2020-08-22
Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more