unifi dns
About 1709 words
Manage local DNS records and DNS policies.
Aliases: dns-policies, dns-records
Manage local DNS records and DNS policies: host records the gateway answers itself, aliases, and domains it forwards to another DNS server.
An object is named by its domain. --value sets the field that fits the record's type: the address of an A or AAAA record, the target of a CNAME, the DNS server of a FORWARD_DOMAIN. Pass --type together with --value when creating a record.
This kind is served by the official Network API.
Commands
unifi dns create: Create a DNS policyunifi dns delete: Delete one or more DNS policiesunifi dns describe: Show every field of one DNS policyunifi dns disable: Disable a DNS policyunifi dns edit: Edit a DNS policy in your editorunifi dns enable: Enable a DNS policyunifi dns get: List the DNS policies, or show oneunifi dns set: Change fields of a DNS policy
unifi dns create
Create a DNS policy.
Usage
unifi dns create <domain> [flags]Create a DNS policy from flags, from a file, or from both.
--set path=value sets any field; address nested fields with dots. Values are read as YAML, so 20 is a number, true a boolean and [a,b] a list. -f reads a manifest or a bare spec (-f - reads standard input); flags are applied on top of it. With a manifest that carries metadata.name, the name argument can be left out.
The quickest way to a valid spec is an existing object: unifi dns get <domain> --output yaml.
Examples
unifi dns create nas.home.arpa --type A_RECORD --value 192.168.40.10
unifi dns create nas.home.arpa --filename dns-policies.yaml
unifi dns create nas.home.arpa -f - < spec.yamlFlags
| Flag | Description |
|---|---|
--enabled | whether the record is active; turn it off with --enabled=false |
-f, --filename <file> | read the object from a manifest or spec file; - reads standard input |
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--set <path=value> | set a field: path=value, repeatable; the value is read as YAML, so numbers, booleans and lists like [a,b] work |
--set-stdin <path> | set the field at this path to what arrives on standard input, for secrets; on a terminal it is asked for, masked |
--ttl <int> | time to live in seconds (0 or more) |
--type <string> | record type: A_RECORD, AAAA_RECORD, CNAME_RECORD, MX_RECORD, TXT_RECORD, SRV_RECORD, FORWARD_DOMAIN |
--value <string> | the record's address, target domain or DNS server, depending on its type |
-y, --yes | do not ask for confirmation |
unifi dns delete
Delete one or more DNS policies.
Usage
unifi dns delete <domain>... [flags]Aliases: rm
Delete one or more DNS policies after confirmation.
Every name is checked before anything is deleted, so a typo deletes nothing. Pass --yes to skip the confirmation, as scripts must. When several objects share a name, --id picks the one to delete.
Examples
unifi dns delete nas.home.arpa
unifi dns delete nas.home.arpa --yesFlags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
--type <string> | pick the object by this field, for objects that share a name: record type |
-y, --yes | do not ask for confirmation |
unifi dns describe
Show every field of one DNS policy.
Usage
unifi dns describe <domain> [flags]Show every field of one DNS policy.
The kinds people look at most are laid out in words, with references shown by name; the others list their fields under the paths that unifi dns set <domain> --set <path>=<value> takes. --output yaml always prints the complete object as the controller spells it.
Secrets such as passphrases and keys read <redacted>. --show-secrets prints them in --output yaml and --output json, never in the text view. When several objects share the name, --id picks one.
Examples
unifi dns describe nas.home.arpa
unifi dns describe nas.home.arpa --output json
unifi dns describe --id <id>Flags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
--show-secrets | print secrets in yaml and json output instead of <redacted>; they end up in your terminal, its scrollback and any file you redirect to |
--type <string> | pick the object by this field, for objects that share a name: record type |
unifi dns disable
Disable a DNS policy.
Usage
unifi dns disable <domain> [flags]Disable a DNS policy. It is a shortcut for unifi dns set <domain> --set enabled=false.
Examples
unifi dns disable nas.home.arpaFlags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
--type <string> | pick the object by this field, for objects that share a name: record type |
-y, --yes | do not ask for confirmation |
unifi dns edit
Edit a DNS policy in your editor.
Usage
unifi dns edit <domain> [flags]Open a DNS policy as a YAML manifest in your editor and apply it on save.
The editor is taken from $VISUAL, then $EDITOR, then vi. What you save becomes the object's new state: removing a field removes it. Closing without changes, or emptying the file, cancels the edit.
Secrets such as passphrases and keys are shown as <redacted>. Leave that as it is to keep a secret, or type a new value over it to change it.
When the result is not a valid manifest or the controller rejects it, your edits are kept in a file whose path is printed, so nothing is lost.
Examples
unifi dns edit nas.home.arpa
unifi dns edit nas.home.arpa # with EDITOR="code --wait"Flags
| Flag | Description |
|---|---|
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--id <id> | pick the object by its id, for objects that share a name |
--type <string> | pick the object by this field, for objects that share a name: record type |
-y, --yes | do not ask for confirmation |
unifi dns enable
Enable a DNS policy.
Usage
unifi dns enable <domain> [flags]Enable a DNS policy. It is a shortcut for unifi dns set <domain> --set enabled=true.
Examples
unifi dns enable nas.home.arpaFlags
| Flag | Description |
|---|---|
--id <id> | pick the object by its id, for objects that share a name |
--type <string> | pick the object by this field, for objects that share a name: record type |
-y, --yes | do not ask for confirmation |
unifi dns get
List the DNS policies, or show one.
Usage
unifi dns get [domain] [flags]Aliases: list, ls
List the DNS policies of the site, or show the one named by the argument.
--output wide adds columns and the object IDs. --output yaml and --output json print manifests that unifi apply -f - accepts unchanged.
--show-secrets keeps passphrases, keys and other secrets in --output yaml and --output json; without it they read <redacted>, which unifi apply understands as "keep the current value". Tables never show secrets.
--filter takes a filter expression such as enabled && name contains "guest". Fields are the object's own, as shown by --output yaml, plus name and id. --sort takes a column: name, type, value, ttl, enabled, or any field path.
Examples
unifi dns get
unifi dns get --output wide
unifi dns get nas.home.arpa --output yaml
unifi dns get --filter 'type == "A_RECORD"'
unifi dns get --output yaml > dns-policies.yamlFlags
| Flag | Description |
|---|---|
--filter <string> | filter expression, such as 'enabled && name contains "guest"' |
--id <id> | pick the object by its id, for objects that share a name |
--reverse | reverse the sort order |
--show-secrets | print secrets in yaml and json output instead of <redacted>; they end up in your terminal, its scrollback and any file you redirect to |
--sort <string> | sort by a column or field path: name, type, value, ttl, enabled |
--type <string> | pick the object by this field, for objects that share a name: record type |
unifi dns set
Change fields of a DNS policy.
Usage
unifi dns set <domain> [flags]Change fields of a DNS policy and show what changed.
--set path=value sets any field; address nested fields with dots. Values are read as YAML, so 20 is a number, true a boolean and [a,b] a list (a list replaces the whole field). --unset path removes a field. --dry-run shows the change without making it.
Find the field paths with unifi dns get <domain> --output yaml.
Examples
unifi dns set nas.home.arpa --value 192.168.40.11
unifi dns set nas.home.arpa --set <path>=<value> --dry-run
unifi dns set nas.home.arpa --unset <path>Flags
| Flag | Description |
|---|---|
--dry-run | show what would change without changing it |
--enabled | whether the record is active; turn it off with --enabled=false |
--force | send fields that no object of the kind on this site has, instead of refusing them as typos |
--id <id> | pick the object by its id, for objects that share a name |
--set <path=value> | set a field: path=value, repeatable; the value is read as YAML, so numbers, booleans and lists like [a,b] work |
--set-stdin <path> | set the field at this path to what arrives on standard input, for secrets; on a terminal it is asked for, masked |
--ttl <int> | time to live in seconds (0 or more) |
--type <string> | record type: A_RECORD, AAAA_RECORD, CNAME_RECORD, MX_RECORD, TXT_RECORD, SRV_RECORD, FORWARD_DOMAIN |
--unset <path> | remove a field by its path, repeatable |
--value <string> | the record's address, target domain or DNS server, depending on its type |
-y, --yes | do not ask for confirmation |
Global flags
These flags are accepted by every command.
| Flag | Description |
|---|---|
--color-scheme <string> | color scheme: auto, dark or light |
--context <string> | context to use instead of the current one |
--no-cache | ask the controller for everything instead of using cached answers |
-o, --output <string> | output format: text, wide, json, yaml (table is another name for text) |
-s, --site <string> | site to act on instead of the context's default site |
--theme <string> | theme to render with instead of the configured one |
