Dnscontrol: Difference between revisions

From NixOS Wiki
imported>Onny
Add see also section
m fix creds.json and dnsconfig.js syntax highlighting
Line 12: Line 12:
In the following example usage, we'll create a credentials file called <code>creds.json</code> with the login details for the domain provider [https://inwx.com Inwx.com]:
In the following example usage, we'll create a credentials file called <code>creds.json</code> with the login details for the domain provider [https://inwx.com Inwx.com]:


{{file|creds.json||<nowiki>
{{file|creds.json|json|<nowiki>
{
{
   "inwx": {
   "inwx": {
Line 26: Line 26:
The second required configuration file called <code>dnsconfig.js</code> defines providers and domain configurations. In this example, we'll add a subdomain <code>test</code> to the domain <code>example.org</code> with a specific A-record.
The second required configuration file called <code>dnsconfig.js</code> defines providers and domain configurations. In this example, we'll add a subdomain <code>test</code> to the domain <code>example.org</code> with a specific A-record.


{{file|dnsconfig.js||<nowiki>
{{file|dnsconfig.js|javascript|<nowiki>
var REG_NONE = NewRegistrar("none");
var REG_NONE = NewRegistrar("none");
var DSP_INWX = NewDnsProvider("inwx");
var DSP_INWX = NewDnsProvider("inwx");

Revision as of 01:23, 23 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