# DNS Client

# DNS Client

This module includes configuration variables for the DNS client.

## Summary

| ### Macros ||
|---|---|
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1gab382a0f967d80661072ec5664ba20230 1` | Define to 1 to enable support for a query of arbitrary DNS record type. |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1ga61e1c7e0039ab557b32b42257c032341 0` | Define as 1 to bind DNS client UDP socket to the internal Thread network interface. |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1ga3fd7977fcb199f86a8916bd1889f81c7 3` | Specifies the default maximum number of DNS query tx attempts with no response before reporting failure. |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1ga6d92f2f5d91ad2aac6392f749bf8e5cb 1` | Specifies the default NAT64 mode, i.e., whether to allow or disallow NAT64 address translation during DNS client address resolution. |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1ga5fb00a453e19da86f97e55e3999b943b 1` |   |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1ga1c21dc5517f8ac4662ef162a73295cd4 7000` | Specifies the default wait time that DNS client waits for a response from server (in milliseconds). |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1ga60f11c183224fd92b02952090e32b4c5 (OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE && OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE)` | Set to 1 for DNS client to automatically set and update the server IPv6 address in the default config (when it is not explicitly set by user). |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1gad0f244f206a841195546841832fe5867 "2001:4860:4860::8888"` | Specifies the default DNS server IPv6 address. |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1gac5a3382047cf13692b3c5ced9d3f6319 53` | Specifies the default DNS server port number. |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1ga1bf7259f99ac236cf6267782aa284517 OT_DNS_SERVICE_MODE_SRV_TXT_OPTIMIZE` | Specifies the default `otDnsServiceMode` to use. |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1ga8d6f68c1947ee96fe10ea22e657afc7e 0` | Define to 1 to enable DNS Client support. |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1gab47319df8a6ab1e6c6c1215a274f6780 1` | Define to 1 to enable support for NAT64 address translation (from IPv4 to IPv6) during address resolution by DNS client. |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1ga567457b68bf24951f90f1e250962e8f4 0` | Enables support for sending DNS Queries over TCP. |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1gac4e0fa8ff347632d976aa2bd5baac89d 1024` | Specifies size of receive and transmit buffers of TCP sockets for DNS query over TCP. |
| `https://openthread.io/reference/config/group/config-dns-client#group__config-dns-client_1gace9a191d336743f880169a2da3d4811d 1` | Define to 1 to enable DNS based Service Discovery (DNS-SD) client. |

## Macros

### OPENTHREAD_CONFIG_DNS_CLIENT_ARBITRARY_RECORD_QUERY_ENABLE

```
 OPENTHREAD_CONFIG_DNS_CLIENT_ARBITRARY_RECORD_QUERY_ENABLE 1
```
Define to 1 to enable support for a query of arbitrary DNS record type.

### OPENTHREAD_CONFIG_DNS_CLIENT_BIND_UDP_TO_THREAD_NETIF

```
 OPENTHREAD_CONFIG_DNS_CLIENT_BIND_UDP_TO_THREAD_NETIF 0
```
Define as 1 to bind DNS client UDP socket to the internal Thread network interface.

When set to 0, the socket is bound to the unspecified network interface, allowing it to send and receive DNS messages over any network interface.

### OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_MAX_TX_ATTEMPTS

```
 OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_MAX_TX_ATTEMPTS 3
```
Specifies the default maximum number of DNS query tx attempts with no response before reporting failure.

### OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NAT64_ALLOWED

```
 OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_NAT64_ALLOWED 1
```
Specifies the default NAT64 mode, i.e., whether to allow or disallow NAT64 address translation during DNS client address resolution.

This mode is only available when `OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE` is enabled.

### OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RECURSION_DESIRED_FLAG

```
 OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RECURSION_DESIRED_FLAG 1
```

### OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT

```
 OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_RESPONSE_TIMEOUT 7000
```
Specifies the default wait time that DNS client waits for a response from server (in milliseconds).

The default value of 7000 is selected to be longer than the six-second wait time for queries resolved by the Discovery Proxy (per RFC 8766, Section 5.6, first bullet).

### OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE

```
 OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_ADDRESS_AUTO_SET_ENABLE (OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE && OPENTHREAD_CONFIG_SRP_CLIENT_AUTO_START_API_ENABLE)
```
Set to 1 for DNS client to automatically set and update the server IPv6 address in the default config (when it is not explicitly set by user).

This feature requires SRP client and its auto-start feature to be also enabled. SRP client will then monitor the Thread Network Data for DNS/SRP Service entries to select an SRP server. The selected SRP server address is also set as the DNS server address in the default config.

### OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS

```
 OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_IP6_ADDRESS "2001:4860:4860::8888"
```
Specifies the default DNS server IPv6 address.

It MUST be a C string representation of the server IPv6 address.

Default value is set to "2001:4860:4860::8888" which is the Google Public DNS IPv6 address.

### OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_PORT

```
 OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVER_PORT 53
```
Specifies the default DNS server port number.

### OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVICE_MODE

```
 OPENTHREAD_CONFIG_DNS_CLIENT_DEFAULT_SERVICE_MODE OT_DNS_SERVICE_MODE_SRV_TXT_OPTIMIZE
```
Specifies the default `otDnsServiceMode` to use.

The value MUST be from `otDnsServiceMode` enumeration.

### OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE

```
 OPENTHREAD_CONFIG_DNS_CLIENT_ENABLE 0
```
Define to 1 to enable DNS Client support.

### OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE

```
 OPENTHREAD_CONFIG_DNS_CLIENT_NAT64_ENABLE 1
```
Define to 1 to enable support for NAT64 address translation (from IPv4 to IPv6) during address resolution by DNS client.

### OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE

```
 OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_ENABLE 0
```
Enables support for sending DNS Queries over TCP.

### OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_QUERY_MAX_SIZE

```
 OPENTHREAD_CONFIG_DNS_CLIENT_OVER_TCP_QUERY_MAX_SIZE 1024
```
Specifies size of receive and transmit buffers of TCP sockets for DNS query over TCP.

### OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE

```
 OPENTHREAD_CONFIG_DNS_CLIENT_SERVICE_DISCOVERY_ENABLE 1
```
Define to 1 to enable DNS based Service Discovery (DNS-SD) client.

## Resources

OpenThread API Reference topics originate from the source code, available
on [GitHub](https://github.com/openthread/openthread/tree/main/include/openthread).
For more information, or to contribute to our documentation, refer to
[Resources](https://openthread.io/resources).