Dnscontrol: Difference between revisions

From NixOS Wiki
imported>Onny
Initial page
 
imported>Onny
mNo edit summary
Line 49: Line 49:
</syntaxhighlight>
</syntaxhighlight>


Confirm changes to the dns record using the tool <code>dig</code>.
<syntaxhighlight lang="console">
# nix shell nixpkgs#dnsutils --command dig +short test.example.org
</syntaxhighlight>


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

Revision as of 10:54, 19 March 2023

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