84 lines
1.5 KiB
Markdown
84 lines
1.5 KiB
Markdown
# 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
|
|
|
|
```bash
|
|
git clone https://gitea.ramoncaballero.dev/mon/pb-dydns.git
|
|
cd pb-dydns
|
|
```
|
|
|
|
### 2. Deploy the script
|
|
|
|
Run the provided deployment script:
|
|
|
|
```bash
|
|
./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:
|
|
|
|
- the Porkbun API endpoint (usually https://api.porkbun.com/api/json/v3/)
|
|
- your Porkbun API key
|
|
- your secret key
|
|
|
|
## 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:
|
|
|
|
```bash
|
|
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.
|