Can cPanel Update Dynamic IP Information To DNS Records?

nim6us

Registered
Mar 2, 2012
2
0
51
cPanel Access Level
Website Owner
I've previously used a the hostname service with DynDNS because it was free. However now that I'm trying to add an bit of professionalism to my freelance work I want to use a custom domain. Right now I've just created a CNAME so that mycustomname.com references mydyndns.com. That way I'm still using the DynDNS service but the client or whoever is none the wiser. Why not just point mycustomname.com at my IP? Well the only reason I still need to use the DynDNS service is because my IP is dynamic and DynDNS allows my router (running Tomato firmware) to update DNS information with my current IP automatically so my hostname is always accurate. However I was wondering is there a way that I can just have my router update cPanel instead of DynDNS and I could use mycustomname.com exclusively and cut out the need for DynDNS?
 

gort42

Registered
Sep 1, 2007
4
0
51
How about making a feature request? There are a number of forum articles asking for this feature, e.g. this recent post, this post from 2006 w/ a poll, or this one from 2005.

The prevailing response is as you've suggested. I recently stumbled onto this Dynamic DNS update via cPanel API script by Stefan Gofferje /http://stefan.gofferje.net/it-stuff/scripts/39-dynamic-dns-update-via-cpanel-api but I haven't found much discussion of folks using it. Stefan has a brief article about it here /http://stefan.gofferje.net.nyud.net/news/website-news/40-dynamic-dns-and-cpanel. I'd be interested to know if you get it working.
 

cPanelNick

Administrator
Staff member
Mar 9, 2015
3,481
35
208
cPanel Access Level
DataCenter Provider
I wrote a shell script a while back to update the dns for my home ip (I'm using this on an openwrt router). I'm posting it inline in case someone finds it useful:

View attachment cpanel-dynamic-dns.sh.txt

Update: The attached script will longer work as of cPanel & WHM version 72. Please monitor the following GitHub repo for upcoming changes to this shell script:

CpanelInc/cpanel-dynamicdns-tools


Thank you.
 
Last edited by a moderator:

doni49

Well-Known Member
Oct 4, 2006
74
0
156
Nick,

I'm attempting to use your script for my own similar needs. But I have a few questions and I'm hoping you can assist.

1) Under the Setup_vars function, what does this do? HOMEDIR=`echo ~` I ask because I would've thought it should be /home/username not a line containing "echo".

2) Under load_config, if $basedir.conf does not exist (which it doesn't), the script will (should) throw an error. So I'm guessing I need to create the file. What belongs in this file?

THANKS!

EDIT: You can disregard Q #1. I just figured out that echo ~ outputs the home folder name (which means that as used, it sets HOMEDIR to the home folder path).
 
Last edited:

cPanelNick

Administrator
Staff member
Mar 9, 2015
3,481
35
208
cPanel Access Level
DataCenter Provider
Here is what my config file in /root/etc/ looks like:

Code:
root@OpenWrt:~/etc# cat cpdyndns.conf 
CONTACT_EMAIL="[email protected]"
CPANEL_SERVER="my_server_here.cpanel.net"
DOMAIN="my_domain_here.tld"
SUBDOMAIN="my_subdomain_here"
CPANEL_USER="my_username_here"
CPANEL_PASS="my_password_here"
 

manokiss

Well-Known Member
Mar 31, 2002
576
1
318
Hi Nick, just a question...do this need root to run? or running through user cron should work? Thanx!
 

manokiss

Well-Known Member
Mar 31, 2002
576
1
318
I keep getting the following error, wondering if you can give me an idea from where start looking? simple and advanced DNS editor is enabled in the user cpanel. Im on whm 11.38

Fetching zone for domain.com....Request failed with error: Unknown Error (Please make sure you have the zoneedit, or simplezone edit permission on your account.)
skipping notification because a notication was sent 28 seconds ago.

Thanx in advance!
 

manokiss

Well-Known Member
Mar 31, 2002
576
1
318
Wondering if this line:

AUTH_STRING=`echo -n "$CPANEL_USER:$CPANEL_PASS" | openssl enc -base64`

Should be changed? is cpanel continue using base64 or md5?
 

manokiss

Well-Known Member
Mar 31, 2002
576
1
318
Thanx Nick!

Could there be anything about the user account that doesn't have perms to that API? Openssl is installed in the client but keep getting auth error....

Thanx again!
 
Last edited by a moderator:

surfrock66

Registered
Oct 14, 2013
3
0
1
cPanel Access Level
Website Owner
Just a heads up, I've been using this script for months but now it isn't working. I'm not sure when it broke; I'd been running it as a cronjob with output redirected to /dev/null, so I have no log.

The output I get when running the script is the following:

surfrock66@sr66-blade:~$ sh /home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh
trap: SIGALRM: bad trap
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 95: [: hda: unexpected operator
==
== cPanel Dyanmic DNS Updater 2.1
==
== Updating domain hda.surfrock66.com
==
== /etc/cpdyndns.conf does not exist
== /home/surfrock66/etc/cpdyndns.conf does not exist
==
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 418: [: 0: unexpected operator
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 421: [: 1000: unexpected operator
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 431: [: [email protected]: unexpected operator
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 434: [: server.secureplusplusfour.net: unexpected operator
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 438: [: surfrock66.com: unexpected operator
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 442: [: <<USERNAME>>: unexpected operator
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 446: [: <<PASSWORD>>: unexpected operator
Determining IP Address...</body></html>...Done
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 142: [: </body></html>: unexpected operator
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 160: [: 71.197.114.191: unexpected operator
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 1: printf: %q: invalid directive
/home/surfrock66/.sr66_hda_scripts/cpanel-dynamic-dns-hda-surfrock66-com.sh: 1: printf: %q: invalid directive
Fetching zone for surfrock66.com....
My username and password are printed out above, so I've removed them. Thoughts?
 

_cedric_

Registered
Nov 19, 2013
1
0
1
cPanel Access Level
Website Owner
Hi, I registered to thank cPanelNick for his script that perfectly fits my needs.

I made two little changes:
- Set the ttl from to 300 to 1800
- Use a precalculated auth string as I don't like to have my login/pass clear in a conf file:
generate_auth_string () {
# AUTH_STRING=`echo -n "$CPANEL_USER:$CPANEL_PASS" | openssl enc -base64`
AUTH_STRING=$PRECALC_AUTH_STRING
}
PRECALC_AUTH_STRING is defined in the .conf file.

For information, the script run on a synology DS106j with DSM 2.1-0844, the cronjob is set to run every two hours.
My domain and cpanel are hosted by hostpapa.com

Best regards :)
Cedric
 

chuq00

Registered
Nov 23, 2013
1
0
1
cPanel Access Level
Website Owner
Here is what my config file in /root/etc/ looks like:

Code:
root@OpenWrt:~/etc# cat cpdyndns.conf 
CONTACT_EMAIL="[email protected]"
CPANEL_SERVER="my_server_here.cpanel.net"
DOMAIN="my_domain_here.tld"
SUBDOMAIN="my_subdomain_here"
CPANEL_USER="my_username_here"
CPANEL_PASS="my_password_here"

Nick I am trying to use this on my ubuntu system and whenever I run this I have bunches of errors
Code:
./cpanel-dynamic-dns.sh: 350: [: 0: unexpected operator
./cpanel-dynamic-dns.sh: 347: [: 0: unexpected operator
./cpanel-dynamic-dns.sh: 350: [: 0: unexpected operator
./cpanel-dynamic-dns.sh: 347: [: 0: unexpected operator
./cpanel-dynamic-dns.sh: 350: [: 0: unexpected operator
./cpanel-dynamic-dns.sh: 347: [: 0: unexpected operator
./cpanel-dynamic-dns.sh: 350: [: 0: unexpected operator
./cpanel-dynamic-dns.sh: 347: [: 0: unexpected operator
./cpanel-dynamic-dns.sh: 350: [: 0: unexpected operator
./cpanel-dynamic-dns.sh: 356: [: unexpected operator
just for a sample of them..
What am I missing? are there some pre-req's that I may be missing?
 

seanos

Registered
Apr 8, 2014
1
0
1
cPanel Access Level
Website Owner
Nick I am trying to use this on my ubuntu system and whenever I run this I have bunches of errors
Code:
./cpanel-dynamic-dns.sh: 350: [: 0: unexpected operator
In case anyone else is running into this problem (with the shutdown of DynDNS free service in a month’s time)—the problem here is the script is being run using sh rather than bash.

Try...
Code:
bash ./cpanel-dynamic-dns.sh
Thanks CpanelNick!
 

Gibby

Member
Feb 24, 2012
9
0
51
cPanel Access Level
DataCenter Provider
Thanks Nick, I was about 50% done with my script since dyndns is going away and I have been using it for years, decided maybe someone has already done what I was trying to do. You saved me some time. It works great on Zentyal which is on top of Ubuntu 12.04.