DDNS on Porkbun

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
ohmic314
DD-WRT Novice


Joined: 09 Dec 2011
Posts: 8

PostPosted: Sun Oct 27, 2024 4:51    Post subject: DDNS on Porkbun Reply with quote
I was unable to get DDNS working with Porkbun using the dd-wrt web GUI, so I thought I would just write a little how-to in case someone else needs help setting it up.
    - Use this website from Porkbun to get the API key and Secret key for your account: https://kb.porkbun.com/article/190-getting-started-with-the-porkbun-api
    - Ssh into the router and run the following command - replace the $DOMAIN, $SECRET_KEY, and $APIKEY with your domain, secret key, and apikey that was obtained from the previous step
    Code:
    curl -sb -X POST https://api.porkbun.com/api/json/v3/dns/retrieve/$DOMAIN -H "Content-Type: application/json" -d "{\"secretapikey\":\"$SECRET_KEY\",\"apikey\":\"$APIKEY\"}"

    - Record the ID for the domain/subdomain that you're looking to update with dd-wrt
      For example, the code will return something like:
      {"status":"SUCCESS","cloudflare":"enabled","records":[{"id":"31415926","name":"subdomain.domain.com","type":"A","content":"5.5.5.5","ttl":"600","prio":"0","notes":null}...
      The id that you need is: 31415926

    - Go to dd-wrt menu item Administration -> Commands box and copy/paste the following code. Be sure to replace YOUR_DOMAIN, YOUR_SECRET_KEY, YOUR_APIKEY, and ID with the ones for your domain
    Code:
    #!/bin/sh

    # Get the current WAN ip address
    CURRENT_IP=`nvram get wan_ipaddr`

    # These options are to retrieve IP address in case of double NAT
    #CURRENT_IP=$(curl -fs4 https://myip.dnsomatic.com/)
    #CURRENT_IP=$(curl -fs4 http://checkip.amazonaws.com/)
    #CURRENT_IP=$(curl --silent http://api.ipify.org/)

    # Compare with the last saved address
    if grep -q "$CURRENT_IP" /tmp/last_wan_ip;
    then
      echo DDNS: No change needed
    else
      echo DDNS: Change needed

      # Write the current IP to the file to compare to later
      echo $CURRENT_IP > /tmp/last_wan_ip

      APIKEY="YOUR_APIKEY"
      SECRET_KEY="YOUR_SECRET_KEY"
      DOMAIN="YOUR_DOMAIN"
      SUBDOMAIN="YOUR_SUBDOMAIN"
      ID="YOUR_ID"

      RESPONSE=$(curl -sb \
          -X POST https://api.porkbun.com/api/json/v3/dns/edit/$DOMAIN/$ID \
          -H "Content-Type: application/json" \
          -d "{\"secretapikey\":\"$SECRET_KEY\",\"apikey\":\"$APIKEY\",\"name\":\"$SUBDOMAIN\",\"type\":\"A\",\"content\":\"$CURRENT_IP\"}")

    fi

    - Click Save Custom
    - Go to Administration -> Management -> Cron -> Additional Jobs and add instructions to run the .rc_custom script every minute and force update every day at 2am
    Code:
    * * * * * root /tmp/.rc_custom
    30 2 * * * root rm /tmp/last_wan_ip

    - Save and Apply/reboot


I hope this helps someone out there!
Sponsor
RemarkableNow
DD-WRT Novice


Joined: 26 Feb 2025
Posts: 1

PostPosted: Sun May 10, 2026 8:46    Post subject: DDNS on Porkbun - dropdown provider no longer works. Reply with quote
Thanks for confirming what I've painstakingly discovered on my own today.

To fill in a bit of background - while ddns does list porkbun as a provider, porkbun changed their API endpoints in 2024, so that plugin no longer functions - it points to https://porkbun.com and it needs to be updated to https://api.porkbun.com. Which is a hard coded constant, so is up to a code jockey to correct. There are possibly other changes to re-work - I did not look further afther that one leapt out at me.

I might create an issue so it can be tracked and handled in the proper channels, but for now, just making this note here.
kernel-panic69
DD-WRT Guru


Joined: 08 May 2018
Posts: 17417
Location: Texas, USA

PostPosted: Sun May 10, 2026 11:37    Post subject: Reply with quote
It uses api.porkbun.com already:

https://svn.dd-wrt.com/browser/src/router/inadynv2/plugins/porkbun.c

https://svn.dd-wrt.com/ticket/7823

_________________
"Life is but a fleeting moment, a vapor that vanishes quickly; All is vanity"
Contribute To DD-WRT
Pogo - A minimal level of ability is expected and needed...
RSS feed for DD-WRT releases (2025)
RSS feed for DD-WRT releases (2024)
RSS feed for DD-WRT releases (2023)

----------------------
Linux User #377467 counter.li.org / linuxcounter.net
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum