A Dynamic DNS Updater for cPanel is a Bash script that automatically updates your DNS records on cPanel whenever your public IP address changes. This tool is particularly useful for users with dynamic IP addresses who want to ensure their domain always points to the correct IP. The script retrieves the current public IP, checks it against the existing DNS record, and updates the record if there is a discrepancy.
- A cPanel account with API access.
curlandjqinstalled on your system.- A
.envfile containing your cPanel credentials and configuration.
-
Clone the Repository: Open your terminal and run the following command to clone the repository:
git clone https://github.com/tylide/dynamic-dns-updater-cpanel-api-in-bash.git cd dynamic-dns-updater-cpanel-api-in-bash -
Create a
.envFile: Create a.envfile in the root directory of the cloned repository and add your cPanel configuration:CPANEL_URL=https://your-cpanel-url CPANEL_PORT=2083 USERNAME=your-username APIKEY=your-api-key DOMAIN=your-domain TTL=300 GET_IP_URL=checkip.amazonaws.com SUBDOMAIN=subdomain NTFY_SERVER=https://ntfy.sh NTFY_TOPIC=dnsupdate NTFY_TOKEN=tk_my_ntfy_token -
Make the Script Executable: Change the permissions of the script to make it executable:
chmod +x update_ip.sh
To run the script manually, execute the following command in your terminal:
./update_ip.shTo ensure that your DNS records are updated automatically, you can set up a cron job:
-
Open the Crontab: Run the following command to edit your crontab:
crontab -e
-
Add a Cron Job: Add the following line to run the script every 5 minutes (adjust the timing as needed):
*/5 * * * * /path/to/your/dynamic-dns-updater-cpanel-api-in-bash/update_ip.shReplace
/path/to/your/dynamic-dns-updater-cpanel-api-in-bash/with the actual path to your script. -
Save and Exit: Save the changes and exit the editor. Your cron job is now set up!
The Dynamic DNS Updater for cPanel is a simple yet effective solution for keeping your DNS records in sync with your dynamic IP address. With easy installation and automation through cron, you can ensure your domain always points to the correct IP.
Feel free to contribute to the project or report any issues you encounter!