Bash script to update the your namecheap.com ddns host. Tested under Macintosh OSX 10.9.4 and RHES 7.0
- Create a A record on namecheap.com for the host you will be updating. Hint: you can update more then one host, i.e.: @ and www. You may also wish to keep a low TTL value for these hosts, i.e: 60-120
- Enable DDNS by Modifing your domain and clicking on the Dynamic DNS entry on the left hand menu. Write down the Password string that is assigned to this domain.
- Edit the section of the script:
# >>>>>>>>>>>>>>>>>>>>>> Start of Configuration >>>>>>>>>>>>>>>>>>>>>>
#
DOMAIN='mydomain.tld'
PASSWORD=''
HOSTS=('myhost1' 'myhost2')
EMAIL=''
CACHED_IP_FILE='/var/tmp/namecheap_ddns_ip_'
#
# <<<<<<<<<<<<<<<<<<<<<< End of Configuration <<<<<<<<<<<<<<<<<<<<<<
Configuration:
DOMAIN
string - name of domain to updatePASSWORD
string - the password given from Namecheap.comHOSTS
array of strings - the array of hosts to updateEMAIL
string - if exists, then an email will be generated on error or change of IP addressCACHED_IP_FILE
string - path to file holding the last set IP address
DOMAIN='kentswidget.com'
PASSWORD='2138530d9dea58fa'
HOSTS=( devserver )
EMAIL='ddns_notices@kentswidget.com'
CACHED_IP_FILE='/var/tmp/namecheap_ddns_ip_'
DOMAIN='kentswidget.com'
PASSWORD='2138530d9dea58fa'
HOSTS=('@' 'www' 'devserver')
EMAIL='ddns_notices@kentswidget.com'
CACHED_IP_FILE='/var/tmp/namecheap_ddns_ip_'
For these examples I will be saving this script in ~/kent/scripts/NamecheapDdnsUpdate.sh
-
Command line (runs one time)
- Open Terminal
- Enter the command $
bash ~/kent/scripts/NamecheapDdnsUpdate.sh
-
Finder (runs one time)
- Open finder and locate NamecheapDdnsUpdate.sh
- Double-click on file
-
Cron (runs every hour)
- Open Terminal
- Enter the command $
crontab -e
- Add a line:
@hourly ~/kent/scripts/NamecheapDdnsUpdate.sh
Fill in the domain, password, and host for your account
- curl line
- $
curl -s https://dynamicdns.park-your-domain.com/update?domain=my.domain.com&password=33598fgc98a1dbcd&host=myhost
- $