All Products
Search
Document Center

Container Compute Service:DNS resolution policies and caching policies

Last Updated:Mar 26, 2026

This topic describes the Domain Name System (DNS) resolution policies and caching policies for Alibaba Cloud Container Compute Service (ACS) clusters.

DNS resolution pipelines

The following diagrams show the DNS resolution pipeline for two scenarios.

Non-containerized applications on Elastic Compute Service (ECS) instances

For example, an application named App runs on an ECS instance, as shown in the following figure.

DNS解析链路1.png

Containerized applications in pods with the ClusterFirst DNS policy

For example, an application named App runs in a pod in a Kubernetes cluster, as shown in the following figure.

DNS解析链路2.png

Resolution policies

Client side

DNS queries from pods are handled through the interfaces provided by glibc. The /etc/resolv.conf file controls how glibc performs DNS resolution. The following table lists the configurable parameters and their default values across environments.

ParameterDescriptionDefault (glibc)ECSClusterFirst podDefault podHost network + Default pod
nameserverThe DNS server that resolves domain names.NoneVPC DNS servers ②CoreDNS cluster IP ③VPC DNS serversVPC DNS servers
searchNon-FQDN domain names are appended with these suffixes before resolution.NoneNone<ns>.svc.cluster.local svc.cluster.local cluster.localNoneNone
ndots:nIf a domain name contains fewer dots than this value, search suffixes are appended before resolution. If it contains more dots, the name is treated as a fully qualified domain name (FQDN) and resolved directly.11511
timeout:nTimeout for each DNS resolution attempt, in seconds.52552
attempts:nMaximum number of retries when a DNS resolution fails.23223
rotateSend DNS queries to nameservers in round-robin order.DisabledEnabledDisabledDisabledEnabled
single-request-reopenIf two DNS requests are sent over the same socket, close the socket after the first request and open a new socket for the second.DisabledEnabledDisabledDisabledEnabled

The following table describes what each DNS policy means for query routing.

DNS policyBehavior
ClusterFirstDNS queries are sent to CoreDNS. Queries that match the cluster domain suffix are resolved by CoreDNS. All other queries are forwarded to upstream nameservers. This is the default policy when dnsPolicy is not specified.
DefaultThe pod inherits the DNS settings of the ECS instance it runs on. DNS queries go directly to the VPC DNS servers, bypassing CoreDNS.
Note

"Default" is not the default DNS policy. When dnsPolicy is not specified, Kubernetes uses ClusterFirst.

① The attempts parameter applies only when the server returns SERVFAIL, NOTIMP, or REFUSED, or when NOERROR is returned with no resolution results. For details, see Introduction to the attempts parameter.

② VPC DNS servers are the default nameservers for ECS instances in the virtual private cloud (VPC). Their IP addresses are 100.100.2.136 and 100.100.2.138. They resolve authoritative domain names and domain names added to Alibaba Cloud DNS PrivateZone.

③ The CoreDNS cluster IP is the IP address of the kube-dns Service in the kube-system namespace. The kube-dns Service forwards DNS queries to CoreDNS for internal domain names, authoritative domain names, and domain names added to Alibaba Cloud DNS PrivateZone.

Note

For more information about resolv.conf configuration, see resolv.conf.

Non-standard environments

The client-side DNS configuration described above applies to environments using glibc. The following environments behave differently.

Alpine Linux (musl libc)

Alpine Linux replaces glibc with musl libc, which introduces several DNS resolution differences:

  • single-request and single-request-reopen are not supported in /etc/resolv.conf.

  • Alpine 3.3 and earlier do not support the search parameter for search domains. This causes service discovery to fail.

  • musl libc sends queries to all nameservers in /etc/resolv.conf in parallel, which prevents NodeLocal DNSCache from optimizing DNS resolution.

  • musl libc sends A and AAAA queries in parallel over the same socket. On older kernel versions, this causes packet loss on the conntrack port.

For more information, see musl libc functional differences from glibc.

Golang and Node.js

Applications built with Golang or Node.js may use a built-in DNS resolver instead of glibc. This can produce significantly different DNS resolution behavior. Check your application's DNS resolution implementation if you observe unexpected behavior.

Internal DNS servers in the cluster

By default, CoreDNS inherits /etc/resolv.conf from the ECS instance that hosts it. CoreDNS then uses the built-in forward plugin to forward DNS queries upstream.

The following table lists the forward plugin parameters and their default values. For the full reference, see forward.

ParameterDescriptionDefault (CoreDNS)Default (NodeLocal DNSCache)
prefer_udpUse UDP to communicate with the upstream server.EnabledDisabled
force_tcpUse TCP to communicate with the upstream server.DisabledEnabled
max_failsNumber of consecutive failed health checks before an upstream server is considered unhealthy.22
expireHow long to keep the connection to the upstream server alive.10s10s
policyPolicy for selecting upstream servers.randomrandom
health_checkInterval between upstream server health checks.0.5s0.5s
max_concurrentMaximum number of concurrent queries to upstream servers.NoneNone
dial timeoutConnection timeout for upstream servers. Decreases dynamically based on actual connection duration.30s30s
read timeoutRequest timeout for upstream servers.2s2s

Caching policies

Client side

The DNS caching policy at the client side depends on the container and application configuration. Configure client-side caching based on your requirements.

Internal DNS servers in the cluster

CoreDNS uses the cache plugin to cache DNS resolution results. The following table lists the cache plugin parameters and their default values in ACS.

ParameterDescriptionDefault (CoreDNS)Default (CoreDNS in ACS)
success Max TTLMaximum time to live (TTL) for cached successful DNS resolutions.3600s30s
success Min TTLMinimum TTL for cached successful DNS resolutions.5s5s
success CapacityMaximum number of successful DNS resolution results to cache.99849984
denial Max TTLMaximum TTL for cached failed DNS resolutions.1800s30s
denial Min TTLMinimum TTL for cached failed DNS resolutions.5s5s
denial CapacityMaximum number of failed DNS resolution results to cache.99849984
ServerError TTLMaximum TTL for DNS results returned from unhealthy upstream servers.5s0s. If the CoreDNS version is earlier than 1.8.4.2, the default is 5s.
serve_staleServe stale cached entries when the upstream server is unreachable.DisabledDisabled
Note

The actual TTL applied to a cached entry is determined as follows:

  • If the DNS record TTL exceeds the maximum TTL, the maximum TTL is used.

  • If the DNS record TTL is below the minimum TTL, the minimum TTL is used.

  • If the DNS record TTL falls between the minimum and maximum TTL, the DNS record TTL is used.

Optimize DNS resolution

Modify the pod YAML file or the CoreDNS ConfigMap to tune DNS resolution behavior.

Use VPC DNS servers directly

Set dnsPolicy: Default to bypass CoreDNS and resolve domain names directly through VPC DNS servers. The pod inherits the DNS settings of the ECS instance that hosts it.

apiVersion: v1
kind: Pod
metadata:
  name: example
  namespace: default
spec:
  containers:
  - image: registry.cn-hangzhou.aliyuncs.com/example-ns/example:v1
    name: example
  # Set the dnsPolicy parameter to Default.
  dnsPolicy: Default

# The /etc/resolv.conf file in the pod.
# cat /etc/resolv.conf
nameserver 100.100.2.136
nameserver 100.100.2.138

Improve fault tolerance for Default pods

When dnsPolicy: Default is set, the pod's /etc/resolv.conf omits the rotate, single-request-reopen, timeout:2, and attempts:3 options that ECS instances include by default. Without these options, DNS resolution is more likely to fail during network jitter.

Add these options using dnsConfig to match the ECS instance behavior:

apiVersion: v1
kind: Pod
metadata:
  name: example
  namespace: default
spec:
  containers:
  - image: registry.cn-hangzhou.aliyuncs.com/example-ns/example:v1
    name: example
  # Set the dnsPolicy parameter to Default.
  dnsPolicy: Default
  # Add the following options.
  dnsConfig:
    options:
    - name: timeout
      value: "2"
    - name: attempts
      value: "3"
    - name: rotate
    - name: single-request-reopen

# After adding the options, redeploy the pod to apply the changes.
# cat /etc/resolv.conf
nameserver 100.100.2.136
nameserver 100.100.2.138
options rotate single-request-reopen timeout:2 attempts:3