Dnscontrol: Difference between revisions

From NixOS Wiki
m fix creds.json and dnsconfig.js syntax highlighting
Klinger (talk | contribs)
 
Line 59: Line 59:


[[Category:Applications]]
[[Category:Applications]]
[[Category:Networking]]

Latest revision as of 19:39, 25 June 2024

Dnscontrol is a tool to synchronize your DNS to multiple providers from a simple DSL.

Installation

Install dnscontrol in your current environment

# nix-env -iA nixos.dnscontrol

Configuration

In the following example usage, we'll create a credentials file called creds.json with the login details for the domain provider Inwx.com:

creds.json
{
  "inwx": {
    "TYPE": "INWX",
    "username": "myuser",
    "password": "mypassword"
  }
}

See upstream documentation for available provider and their authentication syntax.

The second required configuration file called dnsconfig.js defines providers and domain configurations. In this example, we'll add a subdomain test to the domain example.org with a specific A-record.

dnsconfig.js
var REG_NONE = NewRegistrar("none");
var DSP_INWX = NewDnsProvider("inwx");

D("example.org", REG_NONE, DnsProvider(DSP_INWX), NO_PURGE,
    A("test", "1.2.3.4")
);

The provider will be Inwx for which we configured the credentials earlier. The option NO_PURGE tells dnscontrol to only add the new record while leaving all other entries untouched.

Usage

Preview the changes which will be made to your domain

# dnscontrol preview

Apply changes with the following command

# dnscontrol push

Confirm changes to the dns record using the tool dig.

# nix shell nixpkgs#dnsutils --command dig +short test.example.org

See also

  • Octodns, tool that allows for easy management of DNS records across multiple providers