If you do not want to install the desktop update client, you can update your hostname with a small Bash script and a cron job on macOS or Ubuntu.
This guide uses the CheckIP Tool to detect your public IP address and the Dynamic DNS Update API to send the update.
Quick summary
- Open Terminal
- Get your Dyn update client key from your profile page
- Download the script, move it into
~/Dyn, and update it with your hostname and Dyn username - Run the script once so it can create the key file for you
- Paste your key into that file, then run the script again to confirm it works
- Schedule the script to run every 10 minutes
File locations
- Script:
~/Dyn/update-dyndns.sh - Key:
~/.config/dyn/ddns-key - Log:
~/.config/dyn/ddns-update.log
Before you begin
Make sure you have:
- A Dyn account
- A Dynamic DNS hostname or Standard DNS hostname that accepts dynamic updates
- Your Dyn username
- Your update client key
The update API can use either your account password or an update client key. This guide uses and strongly recommends the update client key because it can update your hostname but cannot be used to sign in to your Dyn account.
You can view or generate your update client key on your profile page at https://account.dyn.com/profile/:
- If you do not already have a key, click
Generate Key - If you already have a key, click
Show Key
Use HTTPS for the update request. Do not paste secrets into one-off shell commands that will be written to your shell history.
Security recommendations
Store your update client key in a file with chmod 600.
Recommended file location:
~/.config/dyn/ddns-key
Only the account that runs the cron job should be able to read this file.
Required tools
This script expects these commands to be available:
bashcurlsedheadtrdateinstallcrontab
On Ubuntu, install curl if it is missing:
sudo apt update
sudo apt install curl
On macOS, curl is usually already installed.
Download and prepare the Bash script
- Download update-dyndns.sh into your Downloads folder.
- Open Terminal.
- Create
~/Dynif it does not already exist:
mkdir -p "$HOME/Dyn"
- Move the script from Downloads into
~/Dyn:
mv "$HOME/Downloads/update-dyndns.sh" "$HOME/Dyn/update-dyndns.sh"
- Open the script in a text editor:
nano "$HOME/Dyn/update-dyndns.sh"
- Replace
yourhost.example.comwith your hostname andyour-dyn-usernamewith your Dyn username, then save the file. - Make the script executable:
chmod 700 "$HOME/Dyn/update-dyndns.sh"
Run the script and add your key
Expected first-run behavior: the script creates ~/.config/dyn/ddns-key and then exits. This is normal.
Run the script from Terminal with this command:
bash "$HOME/Dyn/update-dyndns.sh"
On the first run, if the key file does not exist yet, the script creates ~/.config/dyn/ddns-key and stops. Protect
that file with restricted permissions:
chmod 600 "$HOME/.config/dyn/ddns-key"
Open the key file in an editor:
nano "$HOME/.config/dyn/ddns-key"
Paste your update client key into the file, save it, then run the script again:
bash "$HOME/Dyn/update-dyndns.sh"
Test the script before scheduling
After you save your update client key and run the script again, inspect the log file:
tail -n 20 "$HOME/.config/dyn/ddns-update.log"
Common successful responses include good and nochg. If you receive an error response, review the
Return Codes page.
Expected results
- On the first run, if the key file does not exist yet, the script creates
~/.config/dyn/ddns-keyand stops. - After you add your update client key and run the script again, a successful result is usually
goodornochg.
Add the cron job
Edit your crontab:
crontab -e
Use a full path in the cron entry.
On Ubuntu, add this line to run every 10 minutes:
*/10 * * * * /bin/bash /home/youruser/Dyn/update-dyndns.sh
On macOS, the full path usually looks like this:
*/10 * * * * /bin/bash /Users/youruser/Dyn/update-dyndns.sh
Some cron environments may also expand $HOME:
*/10 * * * * /bin/bash "$HOME/Dyn/update-dyndns.sh"
Do not schedule the job more often than every 10 minutes. Dyn guidance for CheckIP and update activity is to space checks apart to reduce load.
Verify that cron is working
Use these checks after saving the crontab:
- Run the script once manually
- Review
~/.config/dyn/ddns-update.log - Confirm the cron entry is installed with
crontab -l - In your Dyn account, confirm the hostname shows the expected IP address and latest update time
If your IP address has not changed, nochg is a normal result.
Troubleshooting
The script does not run from cron
- Use full paths in the script and in the crontab entry
- Make sure the script is executable
- Confirm the cron service is available on your system
The script cannot detect my public IP
- Confirm the system can reach
http://checkip.dyndns.org/ - If CheckIP fails, do not send an update request
- Make sure your
sedexpression still matches the returned page
I receive authentication or abuse responses
- Confirm the username and update client key are correct
- Make sure only one updater is managing the hostname
- Do not schedule checks more frequently than every 10 minutes
Remove the cron job
If you no longer want to use this method:
- Run
crontab -e - Delete the Dyn update line
- Save and exit
- Remove
~/Dyn/update-dyndns.sh, the key file, and the log file if you no longer need them
