Adding hosts to coredns

4.8k Views Asked by At

I have a kubernetes installation running coredns and I want to overwrite certain domains (or better subdomains) to resolve to an internal IP.

So reading this: https://coredns.io/plugins/hosts/, I updared my config (Corefile) to look like this:

.:53 {
    errors
    health {
       lameduck 5s
    }
    ready
    hosts {
        subdomain.my-domain.com 88.77.55.44
        fallthrough
    }
    kubernetes cluster.local in-addr.arpa ip6.arpa {
       pods insecure
       fallthrough in-addr.arpa ip6.arpa
       ttl 30
    }
    prometheus :9153
    forward . /etc/resolv.conf {
       max_concurrent 1000
    }
    cache 30
    loop
    reload
    loadbalance
}

But when I do:

dig subdomain.my-domain.com

I get the external IP of that domain, not 88.77.66.55.

Something is wrong, but it's not clear to me what ...

1

There are 1 best solutions below

0
On

You need to use IP subdomain.domain.com like this:

...
    hosts {
        88.77.55.44 subdomain.my-domain.com
        fallthrough
    }
...

https://coredns.io/plugins/hosts/