Thursday, November 24th 2016 (over 2 years ago)

DNS Record Management Through the CLI

Olli Vanhoja (@OVanhoja)
Leo Lamprecht (@notquiteleo)

Since we introduced our own global DNS service zeit.world earlier this year, most of our customers found it to be pretty awesome and instantly decided to let us take care of their domains' resolution.

Today, we'd like to expand this service even further by allowing you to interface directly with our nameservers by making your domain's DNS records editable.

To get started, you'll need at least version 0.30.0 of the now CLI.

The Command

Let's take a look at how you can exploit the new feature with now's command line interface! In the examples shown below, the placeholder zeit.rocks represents a domain of your choice that was registered with now domains or now alias.

now dns ls

Lists all the DNS records created for domains usingzeit.world. The list doesn't include records generated automatically by the nameserver (like a default SOArecord, A / AAAA records created automatically forALIAS records, and so on).

now dns add

Adds a DNS record to a domain of your choice (registered with now domains or now alias). The following record types are currently being supported:

  • A
  • AAAA
  • ALIAS
  • CNAME
  • MX

This is how the command input needs to look like:

▲ now dns add <domain> <name> <record type> <value> [mx_priority]
  • <domain> is the address owned by the user and previously registered withzeit.world by using the commands now domain add zeit.rocks or now alias
  • <name> is the subdomain that will be prefixed to <domain> (@ as a <name> refers to the domain without any prefix)
  • <record type> contains one of the supported record types shown above
  • <value> indicates the target of the record (like an IP address or a hostname)
  • [mx_priority] sets the priority of a certain MX record and can therefore only be used in conjunction with this record type

Examples

▲ now dns add zeit.rocks ext A 127.0.0.1

Creates an A record that makes the subdomain ext.zeit.rocks resolve to the server located at the IP address 127.0.0.1.

▲ now dns add zeit.rocks @ MX mail.awesome-now.us 10

Creates an MX record which makes the mail server located at mail.awesome-now.us responsible for handling emails sent to an address suffixed with @zeit.rocks.

now dns rm <ID>

Removes a record by its ID shown in the now dns ls listing. Note that it may take up to a couple of hours before the change is fully propagated across our infrastructure.

The API Endpoint

Finally, version 0.7.0 of now-client comes with API wrappers for managing the DNS records within your own application.

The endpoint is called /domains/:domain/records and available in our REST API.

How to Get It

If you've installed Now's command line interface using Now Desktop, the only thing you need to do is make sure that the application is running. Assuming that's the case, the binary will automatically be updated for you in the next few minutes!

However, if that's not the case, we highly recommend you to download it and use it to install the CLI. Afterwards, you're covered!

If you're on a platform that's not yet supported by Now Desktop, simply update/install the command line utility like this: npm install -g now@0.30.0

...

Have fun with now dns!