============================
This script updates a DNS A record hosted by Dreamhost to your current IP address via the Dreamhost API.
You need to have generated an API key from the web panel with permissions for the following requests:
- dns-list_records
- dns-remove_record
- dns-add_record
WARNING: Do not rely on this script to always work perfectly!! Due to the lack of update_record API request, we are forced to delete and then re-add. If there is a problem with the API, we could end up deleting a record and then fail to re-add it. If you have this in cron, it will likely update the next time the script is run, or you could just be left without a DNS record at all.
This script is dependant on the following executables:
bash (this is a bash script after all), wget or curl,
uuidgen, grep, awk, sed, and dig.
The script can be run using either command line options or a configuration file. A sample configuration file is found below.
dynamicdns.bash [-Sdvlh46][-k API Key]
[-r Record] [-i New IP Address] [-L Logging (true/false)]
The dynamicdns.bash utility reads a configuration file or command-line options
to update DNS records for a Dreamhost account. Options provided at the command
line override any options specified within the configuration file.
The options are as follows:
-S Save any options provided via the command line to the configuration file.
-d Save any options provided via the command line to the configuration file and do not update DNS.
-v Enable verbose mode.
-l Enable list-only mode, showing only current value returned by the Dreamhost API.
-h Help text
-4 IPv4 only (Otherwise will try IPv4 and then fall back to IPv6)
-6 IPv6 only mode.
-k \<API Key>
Dreamhost API Key with the permissions dns-list_records, dns-remove_record, and dns-add_record.-r \<Record> The DNS Record to be updated.
-i \<IP Address> Specify the IPv4 Address to update the Record to.
If no address is specified, the utility will use dig to obtain the current public IPv4 Address of your computer.-L \<(true/false)> Enables system logging via the logger command. The configuration file sets logging to true by default.
You can easily add this to your crontab with an entry like
@hourly ~/bin/dreamhost-dynamic-dns/dynamicdns.bash