manage the DNS of a domain name via command-line interface
With our API, it is possible to manage the domains and DNS under your own account and those of your clients. In this article, you will learn how to use CLI tool Restish to retrieve a domain name’s DNS, delete DNS records and add new DNS records. In this example, we use as a test domain janjansen.nl.
Install Restish
brew install danielgtaylor/restish/restish
Create a Restish configuration file to the URL of the HostingNL API and your API token:
vi /Users/mark/.restish
{ "sqrnl": { "base": "https://api.hosting.nl/", "profiles": { "default": { "headers": { "API-TOKEN": "API token" } } } } }
The following is how you query the DNS zone of janjansen.nl.
restish sqrnl/domains/natuurwinkeltje.nl/dns
To delete DNS records, write down the ids of the DNS records above that you want to delete. Ignore the record with type of STD. Next, create a file named delete.json containing the ids of the DNS records you want to delete. Use the following format for this purpose:
[ { "id": 773099 }, { "id": 773101 }, { "id": 773102 }, { "id": 773103 } ]
Then use the command below to remove the relevant records from the DNS zone of janjansen.nl
restish delete sqrnl/domains/janjansen.nl/dns <delete.json
To add new DNS records to janjansen.nl’s DNS zone, create a file named zone.json containing the new DNS records. Use the following format for this purpose:
[ { "content": "ns1.hosting.nl", "name": "janjansen.nl", "prio": "0", "ttl": "86400", "type": "NS" }, { "content": "ns2.sqr.domains", "name": "janjansen.nl", "prio": "0", "ttl": "86400", "type": "NS" }, { "content": "ns3.sqr.cloud", "name": "janjansen.nl", "prio": "0", "ttl": "86400", "type": "NS" }, { "content": "1.2.3.4", "name": "janjansen.nl", "prio": "0", "ttl": "3600", "type": "A" } ]
Then add all new DNS records using the command below:
restish post sqrnl/domains/natuurwinkeltje.nl/dns <zone.json