Making Internal DNS for service registered in consul


So i have consul agent and server running and i am able to access the service from consul agent.
But i want to access this service using DNS which is outside the consul cluster but inside my network?
I read about DNS forwarding but then that will require DNS server to be setup on each consul box.
So i really wanted to know if i can take any other approach for this or my above approach is my last resort?


Hey @jainprakhar002

Not sure if i’m understanding your use case correctly, but have you looked into setting recursors in your agent config? Recursors allow you to set an upstream DNS server to resolve requests.

You can also set recursor timeouts in your dns_config

The thing I don’t like about the recursors approach, is that it requires you to reroute your entire network’s DNS traffic through Consul, just to enable resolution of a specific subdomain - which feels like an unnecessary dependency.

I think it’s better to delegate the Consul subdomain to the Consul servers, so any issues with Consul won’t affect the rest of DNS.

However, @jainprakhar002 , I don’t really understand what you’re asking…

Consul already has a built-in DNS server, so no?

What do you mean by “DNS forwarding” exactly ?

Ok my bad i think i confused you about the DNS server thing.
In simple terms what i want to achieve is this: should reach my service which is registered in consul and service being run on lets say 9393 port and also i will use this dns to reach my service inside my network and not from the internet.
Is this possible to do in consul?

Actually i want to solve this problem Making Internal DNS for service registered in consul - #4 by jainprakhar002

1 Like

Glad to see you got it working! :slight_smile:

nope i have not got it working