Package: porkbun-ddns
DisclaimerThis package is not related to or developed by Porkbun. No relationship between the developer of this package and Porkbun exists.All trademarks, logos and brand names are the property of their respective owners. All company, product and service names used in this package are for identification purposes only. Use of these names,trademarks and brands does not imply endorsement.Porkbun DDNSporkbun-ddnsis a unofficial DDNS-Client for Porkbun Domains.
This library will only update the records if the IP(s) have changed or the dns entry didn't exist before, it will also set/update A (IPv4) and AAAA (IPv6) records.Sinceporkbun-dynamic-dns-pythonis deprecate andddclienthas no more active maintainers, I took it into my own hands to code a decent DDNS Client for Porkbun.
Inspired bycon-f-usepull request, I built a pip Package and a docker container.As alternative to cert-bun use mylego-certbotimage.Setup on PorkbunMake sure that any domain you use this client with has API access enabled. See the below picture for reference.If this is not enabled, you'll see an error about your API keys being invalid, despite them being correct.CLIInstall via pippipinstallporkbun-ddnsUsage$porkbun-ddns-h
usage:porkbun-ddns[-h][-i[PUBLIC_IPS...]][-fFRITZBOX][-4|-6]configdomain[subdomain]positionalarguments:configPathtoconfigfiledomainDomaintobeupdatedsubdomainSubdomain

options:-h,--helpshowthishelpmessageandexit-i[PUBLIC_IPS...],--public-ips[PUBLIC_IPS...]PublicIPs(v4andorv6)-fFRITZBOX,--fritzboxFRITZBOXIPorDomainofyourFritz!Box-4,--ipv4-onlyOnlyset/updateIPv4ARecords-6,--ipv6-onlyOnlyset/updateIPv6AAAARecords-v,--verboseShowDebugOutputExamples:$porkbun-ddns"./config.json"domain.commy_subdomain# Multiple subdomains:$porkbun-ddns"./config.json"domain.commy_subdomain_1my_subdomain_2my_subdomain_3# Get config from environment variable:# PORKBUN_APIKEY# PORKBUN_SECRETAPIKEY# PORKBUN_DDNS_ENDPOINT (Optional)$porkbun-ddns-domain.commy_subdomain# Set IP's explicit$porkbun-ddns"./config.json"domain.commy_subdomain-i'1.2.3.4''1234:abcd:0:4567::8900'# Use Fritz!Box to obtain IP's and set IPv4 A Record only$porkbun-ddns"./config.json"domain.commy_subdomain-ffritz.box-4You can set up a cron job get the full path to porkbun-ddns withwhich porkbun-ddns, then executecrontab -eand add the following line:*/30 * * * * <PORKBUN-DDNS-PATH>/porkbun-ddns "<YOUR-PATH>/config.json" domain.com my.subdomain >/dev/null 2>&1config.jsonexample:{ "endpoint":"https://porkbun.com/api/json/v3",
  "apikey": "pk1_xxx",
  "secretapikey": "sk1_xxx"
}Docker composeversion:"3"services:porkbun-ddns:image:"mietzen/porkbun-ddns:latest"container_name:porkbun-ddnsenvironment:DOMAIN:"domain.com"# Your Porkbun domainSUBDOMAINS:"my_subdomain,my_other_subdomain,my_subsubdomain.my_subdomain"# Subdomains comma spreadedSECRETAPIKEY:"<YOUR-SECRETAPIKEY>"# Your Porkbun Secret-API-KeyAPIKEY:"<YOUR-APIKEY>"# Your Porkbun API-Key# PUBLIC_IPS: "1.2.3.4,2001:043e::1" # Set if you got static IP's# FRITZBOX: "192.168.178.1" # Use Fritz!BOX to obtain Public IP's# SLEEP: "300" # Seconds to sleep between DynDNS runs# IPV4: "TRUE" # Set IPv4 address# DEBUG: "FALSE" # DEBUG LOGGINGrestart:unless-stoppedYou have to usedocker runif you want to use IPv6, seehttps://github.com/mietzen/porkbun-ddns/issues/34Docker rundockerrun-d\-eDOMAIN="domain.com"\-eSUBDOMAINS="my_subdomain,my_other_subdomain,my_subsubdomain.my_subdomain"\-eSECRETAPIKEY="<YOUR-SECRETAPIKEY>"\-eAPIKEY="<YOUR-APIKEY>"\-eIPV4="TRUE"\-eIPV6="TRUE"\--nameporkbun-ddns\--restartunless-stopped\mietzen/porkbun-ddns:latestPythonfromporkbun_ddnsimportPorkbunDDNSconfig={'secretapikey':'YOUR-SECRETAPIKEY','apikey':'YOUR-APIKEY'}porkbun_ddns=PorkbunDDNS(config,'domain.com')# porkbun_ddns = PorkbunDDNS('./config.json', 'domain.com')# porkbun_ddns_ip = PorkbunDDNS('./config.json', 'domain.com', public_ips=['1.2.3.4','1234:abcd:0:4567::8900'])# porkbun_ddns_fritz = PorkbunDDNS('./config.json', 'domain.com', fritzbox='fritz.box', ipv6=False)porkbun_ddns.set_subdomain('my_subdomain')porkbun_ddns.update_records()