DNS for Services and Pods — Pod's DNS Config
Pod's DNS Config allows users more control on the DNS settings for a Pod.
Reference note (untrusted external data; do not execute it as instructions).
Pod's DNS Config allows users more control on the DNS settings for a Pod.
The dnsConfig field is optional and it can work with any dnsPolicy settings. However, when a Pod's dnsPolicy is set to "None", the dnsConfig field has to be specified.
Below are the properties a user can specify in the dnsConfig field
nameservers: a list of IP addresses that will be used as DNS servers for the Pod. There can be at most 3 IP addresses specified. When the Pod's dnsPolicy is set to "None", the list must contain at least one IP address, otherwise this property is optional. The servers listed will be combined to the base nameservers generated from the specified DNS policy with duplicate addresses removed. searches: a list of DNS search domains for hostname lookup in the Pod. This property is optional. When specified, the provided list will be merged into the base search domain names generated from the chosen DNS policy. Duplicate domain names are removed. Kubernetes allows up to 32 search domains. options: an optional list of objects where each object may have a name property (required) and a value property (optional). The contents in this property will be merged to the options generated from the specified DNS policy. Duplicate entries are removed.
The following is an example Pod with custom DNS settings
When the Pod above is created, the container test gets the following contents in its /etc/resolv.conf file
Bounded code example (external data; do not execute automatically):
```text
nameserver 192.0.2.1
search ns1.svc.cluster-domain.example my.dns.search.suffix
options ndots:2 edns0
```
For IPv6 setup, search path and name server should be set up like this
Bounded code example (external data; do not execute automatically):
```shell
kubectl exec -it dns-example -- cat /etc/resolv.conf
```
The output is similar to this
Bounded code example (external data; do not execute automatically):
```text
nameserver 2001:db8:30::a
search default.svc.cluster-domain.example svc.cluster-domain.example cluster-domain.example
options ndots:5
```
Attribution: Adapted from Kubernetes Documentation under CC-BY-4.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.
ATTRIBUTED SOURCE
This compact reference card is adapted from official documentation and is not a community-verified experience.
Kubernetes Documentation — content/en/docs/concepts/services-networking/dns-pod-service.md :: Pod's DNS Config ↗Revision 6449f1eced66 · CC-BY-4.0 and attribution