Closed Azuriye closed 2 hours ago
Can you give an example how you use porkbun-ddns?
Do you use docker? Docker compose? Or the CLI Client?
Currently I am using porkbun-ddns in python with cron.
from requests import get
from socket import getaddrinfo, AF_INET, AF_INET6
from porkbun_ddns import PorkbunDDNS
from porkbun_ddns.config import Config, DEFAULT_ENDPOINT
API_KEY = ''
SECRET_API_KEY = ''
query4_address = getaddrinfo('domain.com', None, AF_INET)[0][4][0]
query6_address = getaddrinfo('domain.com', None, AF_INET6)[0][4][0]
my_ipv4 = get('https://api.ipify.org').text
my_ipv6 = get('https://api6.ipify.org').text
if (query4_address != my_ipv4) or (query6_address != my_ipv6):
config = Config(DEFAULT_ENDPOINT, API_KEY, SECRET_API_KEY)
porkbun_ddns_ip = PorkbunDDNS(config, 'domain', public_ips=[my_ipv4, my_ipv6])
porkbun_ddns_ip.update_records()
else:
print("DNS records are up to date.")
Currently I am using porkbun-ddns in python with cron.
from requests import get from socket import getaddrinfo, AF_INET, AF_INET6 from porkbun_ddns import PorkbunDDNS from porkbun_ddns.config import Config, DEFAULT_ENDPOINT API_KEY = '' SECRET_API_KEY = '' query4_address = getaddrinfo('domain.com', None, AF_INET)[0][4][0] query6_address = getaddrinfo('domain.com', None, AF_INET6)[0][4][0] my_ipv4 = get('https://api.ipify.org').text my_ipv6 = get('https://api6.ipify.org').text if (query4_address != my_ipv4) or (query6_address != my_ipv6): config = Config(DEFAULT_ENDPOINT, API_KEY, SECRET_API_KEY) porkbun_ddns_ip = PorkbunDDNS(config, 'domain', public_ips=[my_ipv4, my_ipv6]) porkbun_ddns_ip.update_records() else: print("DNS records are up to date.")
To set subdomains you can do the following:
subdomains = ['subdomain1', 'subdomain2', 'subdomain3']
for subdomain in subdomains:
porkbun_ddns.set_subdomain(subdomain)
porkbun_ddns.update_records()
If you want to set the root domain in the same loop use:
subdomains = ['@', 'subdomain1', 'subdomain2', 'subdomain3']
for subdomain in subdomains:
porkbun_ddns.set_subdomain(subdomain)
porkbun_ddns.update_records()
Also have a look at the entry point of the docker file:
I close the issue but feel free to leave another comment if you got further questions.
So far this package works fine for updating my A/AAAA records for my root domain, but how do I use it only for updating certain sub-domain A/AAAA records?