Script in PHP to update DNS type A records on porkbun.com using their API
Go to file
Ramon Caballero 7162d3aad8 Update README.md 2026-04-07 11:38:09 +01:00
bin Add unit tests 2026-04-07 00:07:52 +01:00
config Refactor existing code into classes 2026-04-06 22:52:51 +01:00
src Validate Porkbun responses defensively 2026-04-07 09:06:42 +01:00
tests Add unit tests 2026-04-07 00:07:52 +01:00
.gitignore Add unit tests 2026-04-07 00:07:52 +01:00
README.md Update README.md 2026-04-07 11:38:09 +01:00
composer.json Add unit tests 2026-04-07 00:07:52 +01:00
composer.lock Add unit tests 2026-04-07 00:07:52 +01:00
phpunit.xml Add unit tests 2026-04-07 00:07:52 +01:00

README.md

pb-dydns

Script in PHP to update DNS type A records on porkbun.com using their API.

This can easily be adapted to other registrars or scripting languages.

Prerequisites

  • At least one domain in porkbun.com with DNS type A records already pointing to your dynamic IP address.
  • Access to the Porkbun API (API key + secret key).

Installation & Deployment

1. Clone the repository

git clone https://gitea.ramoncaballero.dev/mon/pb-dydns.git
cd pb-dydns

2. Deploy the script

Run the provided deployment script:

./deploy.sh

This creates a directory:

$HOME/pb-dydns-live

Inside it you will find:

  • pb-dydns.php (the script you run)
  • PorkbunAPI.php
  • UpdateDnsCommand.php
  • Config.php
  • Logger.php
  • pb-dydns.json (your configuration file)
  • pb-dydns.log (log file)

3. Configure it

Edit the configuration file $HOME/pb-dydns-live/pb-dydns.json

Fill in:

How to use it

From the command line

$ php /path/to/pb-dydns-live/pb-dydns.php yourdomain.com

As a cron job

Edit your crontab:

crontab -e

Add a line like:

*/10 * * * *    php /path/to/pb-dydns-live/pb-dydns.php yourdomain.com > /dev/null

This runs the updater every 10 minutes.

Logs

DNS updates are written to /path/to/pb-dydns-live/pb-dydns.log

Runs where nothing changes do not produce log entries.