Pulvinar tempor cras amet ac turpis tristique tristique ... (read more)close
Pulvinar tempor cras amet ac turpis tristique tristique ... (read more)close

LukeTaylor.org Blog

Making I.T that little bit easier !

Cpanel Dyndns Alternative Using Linux and a CronTask

by in Linux Blog
  • Font size: Larger Smaller
  • Hits: 9837
  • 5 Comments
  • Subscribe to this entry
  • Print
9837

b2ap3_thumbnail_images.jpg

 

A quick and easy guide on how to update Cpanel A records automatically from a Linux server with your current ip address . This can be used to give a perminant DNS hostname to a Dynamic Ip address.

 

Info : What i am trying to acomplish - I have a home server which i like to remote into every now and then , because my ISP uses dynamic Ip addressing this causes my IP to change and i cant remote in . Dyndns.org used to offer the service which allowed you to use a hostname instead of your ip address and most home routers would automatically update this . The Free Dyndns service has now ceased so heres a guide on how to acomplish the same using Cpanel.

1.) To acomplish this task you need a domain hosted on cpanel . My domain Luketaylor.org uses cpanel.


2.) Inside Cpanel i set up a new Host A record and point this to my home server IP e.g. " Remote.Luketaylor.org" >> 92.66.77.54

3.) On any Linux based server ( or Linux based Router ) make a directory in the root called scripts

4.) Place the following script inside DOWNLOAD HERE

5.) Remove the .txt from the end of the file

5.) Edit the following lines

Place your working email in the line below

CONTACT_EMAIL=""

Put your domain name excluding any record before the domain name

}DOMAIN="DOMAIN.org"

This field should be the Hosta record you placed in cpanel , mine for e.g. was "Remote"

SUBDOMAIN="Remote"

}

Ip of your CPANEL host

CPANEL_SERVER="0.0.0.0"

USERNAME of your cpanel server

CPANEL_USER="username"

password of your cpanel server

CPANEL_PASS="password"

 

Creating the Config File

1.) Goto /Etc in root and create a file called cpdyndns.conf

2.) place the following information inside , you can copy it from what you wrote above

Place your working email in the line below

CONTACT_EMAIL=""

Put your domain name excluding any record before the domain name

DOMAIN="DOMAIN.org"

This field should be the Hosta record you placed in cpanel , mine for e.g. was "Remote"

SUBDOMAIN="Remote"

Ip of your CPANEL host

CPANEL_SERVER="0.0.0.0"

USERNAME of your cpanel server

CPANEL_USER="username"

password of your cpanel server

CPANEL_PASS="password"

 

 

Creating the crontask

1.) use the command " Crontab -e " in a command shell

2.) insert the following command ( will execute the script every 45 mins)

 0/45 * * * * /Scripts/cpanel-dynamic-dns.sh

 

Rate this blog entry:

Comments

  • Guest
    kakker Monday, 24 November 2014

    Pretty awesome. I'm wondering if you might have any thoughts/suggestions/advice about 1) running this in FreeNAS, and 2) perhaps using something a bit more secure than basic authentication?

    Thanks. :D

  • Guest
    Luke Taylor ® Tuesday, 25 November 2014

    I have never used Freenas , i assume you can place the script inside a directory within /MNT/ ?
    And then use crontab to automate "just adjust the code to represent the new data path"

    Unfortunately , i never made this script so unsure if theres a way to change the authentication method , for my purpose its fine .

    Thanks for the comment
    Luke

  • Guest
    Isaac Eiland-Hall Thursday, 23 April 2015

    Looks like you removed the script? If you're willing to share it, I'm /u/daychilde on reddit or isaac at panamacitypc dot com :D

  • Guest
    Luke Taylor ® Sunday, 01 October 2017

    Script updated .
    Regards
    Luke

  • Guest
    Jordan Friday, 29 December 2017

    This is outstanding and was exactly what I needed. Works great!

    If you ever want to improve it, adding support to take a custom config file as input to the script would be useful so that it could be called with different "arguments".

Leave your comment

Guest Sunday, 15 December 2019