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.

  1. Install Restish

    brew install danielgtaylor/restish/restish
  2. 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"
            }
          }
        }
      }
    }
  3. The following is how you query the DNS zone of janjansen.nl.

    restish sqrnl/domains/natuurwinkeltje.nl/dns
  4. 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
      }
    ]
  5. 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
  6. 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"
        }
    ]
  7. Then add all new DNS records using the command below:

    restish post sqrnl/domains/natuurwinkeltje.nl/dns <zone.json

Need help from one of our hosting gurus?

Do you need an urgent answer to a question or help from our support? Our hosting specialists are more than happy to assist you!

Customer Support Team

Our customer service is currently closed. We will reopen on the next working day at 08:30 hour

Of neem een kijkje in onze 'stap-voor-stap' support handleidingen.

View support articles