LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

Command-Line DNS: Using the Porkbun API in Shell Scripts

PorkbunI 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:

  1. Get your API keys.
  2. 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


curl --header "Content-Type: application/json" \
  --request POST \
  --data '{ 
    "apikey" : "MY_API_KEY",
    "secretapikey" : "MY_SECRET_KEY",
    "name" : "example",
    "type" : "A",
    "content" : "",
    "ttl" : "600"
  }' \

When run, it returns:

# ./dns.sh 

And to verify:

# nslookup example.lowend.party

Non-authoritative answer:
Name: example.lowend.party


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.




1 Comment

  1. Many thanks. Just what I needed with a few little adjustments. Enjoy your day!

    September 14, 2023 @ 12:50 pm | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

Your email address will not be published. Required fields are marked *