A lightweight Bash script that retrieves your public IP address and updates DNS records on Porkbun automatically using their API.
Rotates IP services to avoid rate limiting.
Writes to a status file info of the last script execution.
This script supports multiple records, each with its own configurable:
- Domain
- TTL
- Type (e.g., A, AAAA)
- Subdomain (supports root
@, wildcard*, and normal subdomains)
- Script fetches your current public IP.
- Compares it with the previously saved IP (stored locally).
- If the IP has changed, it updates your configured DNS records via the Porkbun API.
- If unchanged, it can still update in case Porkbun was out of sync.
-
Clone the repository
git clone https://github.com/kylmp/porkbun-ddns.git
-
Enter the directory
cd porkbun-ddns -
Copy and configure the config file
cp ddns.conf.example ddns.conf
Then edit
ddns.conf:nano ddns.conf
-
If needed, update the config path in the script (line 4)
-
Make the script executable
chmod +x ddns.sh
-
(Optional) Restrict permissions
chmod 600 ddns.conf
Before testing:
- Ensure Porkbun already has DNS records matching each entry in your
ddns.conf. - For testing, set them temporarily to a random IP in the Porkbun dashboard.
Then run:
./ddns.shRefresh the Porkbun UI and verify that the DNS records have been updated to your current public IP.
You should run this script automatically every 5 minutes.
-
Find the full path to the script:
realpath ddns.sh
-
Edit crontab:
crontab -e
-
Add this line (update the path accordingly):
*/5 * * * * /path/to/porkbun-ddns/ddns.sh >/dev/null 2>&1
This ensures your DNS stays up to date whenever your public IP changes.
Based originally on the script found here https://github.com/luxeon/porkbun-ddns