I think people fall into three categories when it comes to managing their DNS:
- Most people manage their DNS via a web browser: logging into their registrar, provider, panel, or third-party DNS provider and using their GUI to change DNS records.
- Those who have seven-figure manage their DNS through a series of baroque cloud API calls.
- And there are is a hardcore who manage their own DNS, thank you very much, and just jump into their zone files and probably use their own optimized system for managing serial numbers.
But what if you’re like me: a guy who can’t be bothered to run his own DNS server because he’s lazy, but when he finds himself in the command-line LowEndZone (ten terminal windows open, remnants of caffeinated beverages littering the desk, Willie Jones in the headphones), he hates to orthogonally break interface semantics and groan over to a web browser to update DNS hosted at his registrar?
In such a case, you might enjoy the Porkbun API. While the official examples use Python and Java, it’s just POSTing JSON and you can do that easily with curl as well.
Getting Started
To get started with the Porkbun API, you start by reading the article entitled Getting Started with the Porkbun API. Yes, it’s all going to be pretty much this straight-forward.
Follow instructions to do two things:
- Get your API keys.
- Turn on API access for the domain(s) you want to work with (it’s off by default).
Sample Use
Here’s a script that will create an A record called ‘example.lowend.party’, resolving 192.168.1.1.
#!/bin/bash curl --header "Content-Type: application/json" \ --request POST \ --data '{ "apikey" : "MY_API_KEY", "secretapikey" : "MY_SECRET_KEY", "name" : "example", "type" : "A", "content" : "1.2.3.4", "ttl" : "600" }' \ https://porkbun.com/api/json/v3/dns/create/lowend.party echo
When run, it returns:
# ./dns.sh {"status":"SUCCESS","id":302181389}
And to verify:
# nslookup example.lowend.party 8.8.8.8 Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: example.lowend.party Address: 1.2.3.4 #
Full-Featured API
With the Porkbun API, you can do all the basic CRUD operations: create, retrieve, update, and delete. Retrieval includes by domain, so it’s possible to list all records for a domain.
Check the API docs for all the details, and then use the above curl script as a template because all you’ll be changing is the JSON you send and the API endpoint.
Related Posts:
- It’s Been a Minute: GanderWeb is Back with Cheap VPS Offers in the UK! - September 14, 2024
- “Can You Wow Our Readers?” Rackdog’s Answer: “Hold My Beer!”Cheap Dedicated Servers in London UK! - September 12, 2024
- Virtvm: Crazy Wonderful Prices in Frankfurt, Germany: 12GB RAM for $3.99/Month! - September 11, 2024
Many thanks. Just what I needed with a few little adjustments. Enjoy your day!