# DNS

> The DNS check - one record type of one name, the values it must contain, and which resolver answers.

A DNS check asks for one record type of one name and passes when the answer contains every expected value. With no expected values, any non-empty answer passes.

```json
{
  "type": "dns",
  "name": "example.com",
  "record": "MX",
  "expect": ["mail.example.com"]
}
```

| Field      | Type             | Default  | Rules                                                    |
| ---------- | ---------------- | -------- | -------------------------------------------------------- |
| `name`     | string           | required | A domain name                                            |
| `record`   | string           | required | `A`, `AAAA`, `CNAME`, `MX`, `TXT` or `NS`                |
| `resolver` | string           | none     | The resolver to ask, as an IP address or a name; port 53 |
| `expect`   | array of strings | `[]`     | Up to 20 values; each one must be in the answer          |

## How answers compare

Answers are compared as text:

- addresses in their canonical form (`2001:db8::1`, not `2001:0db8:0:0:0:0:0:1`);
- names in lowercase without the trailing dot;
- `MX` as `"<preference> <exchange>"`, for example `10 mail.example.com`. An expected value matches either the full form or the exchange alone;
- `TXT` as the concatenation of its strings.

A failed run lists the answers it got, so you can see what the record holds now.

## Which resolver answers

- the resolver the check names, after its address passes the [node's address rules](https://docs.monitorly.cloud/concepts/nodes.md#what-platform-nodes-may-not-reach);
- otherwise, on a platform node, fixed public resolvers;
- otherwise the node's system resolver.

Platform nodes refuse single-label names (such as `intranet`): only the node's own network could answer them. Use a [private node](https://docs.monitorly.cloud/nodes/install.md) for internal zones.

Failures: `dns.nxdomain` when the name does not exist, `dns.no_records` when it has no records of this type, `dns.failed` when the resolver gives no answer, and a list of missing values when an expected value is not in the answer.
