Corefile for adding additional nameserver to CoreDNS configuration file in OCP 4

Solution Verified - Updated -


  • Red Hat OpenShift Container Platform(OCP) v4.1
  • Red Hat OpenShift Container Platform(OCP) v4.2
  • Red Hat OpenShift Container Platform(OCP) v4.3
  • CoreDNS


  • How to add additional upstream nameserver for a specific domain to CoreDNS in OCP 4?
  • Configure two different upstream nameservers, One used to resolve default requests/domains, and the other one for a specific domain.
  • Can I modify CoreFile directly to add the nameserver?


  • Is it NOT recommended or supported to add additional upstream nameserver by directly modifying the Corefile.

  • This feature is available only from OCP v4.3 with the help of DNS Operator API:

# oc patch dns.operator/default --type=merge --patch='{"spec":{"servers":[{"name":"test","zones":["example.local",""],"forwardPlugin":{"upstreams":["<DNS_server_ip>"]}}]}}'


# oc edit dns.operator/default 
  - forwardPlugin:
      - "<DNS1_server_IP>"
      - "<DNS2_server_IP>"
    name: test
    - example.local
  • Verify the changes:
# oc get configmaps/dns-default -n openshift-dns -o yaml

Root Cause

  • API is forwarding to the upstream nameserver by domain. This API definition shows the API functionality of this feature.
  • As of now forward plugin is supported in OCP v4.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.