Skip to content

BashPlus for DNS Made Easy

monstruooo edited this page May 5, 2017 · 51 revisions

1. Getting started

2. Listing/Creating records

3. Updating records

4. Deleting records

5. Working with dnsme_api

6. More dnsme features


Getting started

You start by sourcing bash+ functions

When you first run any command, you are prompted for your API keys. Your keys are then saved as variables inside your shell and will persist until your close the current shell session

If you want to enter your credentials again, run command dnsme cfg reset

Next you list your domains and create a new domain

As you could notice the new domain has become visible only after command dnsme updatedb This is because bash+ works from local cache. When you list your domains for the first time, bash+ detects that there is no cache and downloads the list of domains from the API. However, once the cache is filled, dnsme ls doesn't attempt to contact the API again and continues to use the cache until you issue command dnsme updatedb


Listing/Creating records

Next we create two A records, one of them naked. Notice that until dnsme updatedb is run, new records are not listed. This is because dnsme ls uses local cache

Next we are adding a TXT and a CNAME. Notice again the use of dnsme updatedb to refresh the domain data Also, notice how you can configure a different TTL than default 1800

If you want to create records of other types, consult the API documentation

For example, for an MX record you will need additional mxLevel field

So you will add mxLevel= to the list of arguments of dnsme mk


Updating records

You update records the same way you create them with the exception of naked records. For normal records just run dnsme mk again with new values

For naked records, you need to specify their id to identify them

You can add id when working with any existing record, not only naked. This may even make the command run a bit faster


Deleting records

You delete records by their ids. Notice again the use of dnsme updatedb to refresh the list of records


Working with dnsme_api

To keep you away for trouble, bash+ doesn't have a command to delete domains. You have to do it manually in GUI. However, if you can easily issue your own API requests using bash+ dyn api command. This is how you can do it.

So instead of dnsmeapi.pl, you call function dnsme api.

You don't need to specify the -H accept: and -H content-type headers because dnsme api adds them automatically anyway. You only need to pass -X and -d parameters along with the url.

According to the manual, the data part should look like {[""]}. In reality, [] works just as well.

While you can grep the id from dnsme ls, bash+ has function dnsme domain id that can do the same more easily.

-n $id is a bash trick to check if the variable has a value.

You can check the result of dnsme api thru variable res_code. If it's 0, the command completed successfully.

Another variable set by dnsme api is res. This variable contains the actual response from the API.

in the example below, res contains a json with the list of domains downloaded from the API by dnsme updatedb>


More dnsme features

dnsme cat and dnsme cat will print the list of domains or the records of a particular domain respectively.

These are original configuration jsons returned by the API. dnsme cat works from the local cache. Use _dnsme updatedb> to update the cache to see the latest changes.

Clone this wiki locally