By default Consul runs its own DNS on port 8600. Registered services can be discovered through this DNS resolver with specific domain.
Let’s say you have a service registered in Consul with the name
myservice1. Then, making a
myservice1.service.consul DNS query to Consul DNS running by default on port 8600 will give you the IP address of the node where
myservice1 is running.
Even better, Consul supports SRV DNS record. Instead of the usual A record, you can write your code to request SRV record instead. SRV record contains not only the IP address but also the port of
myservice1, perfect for the case if
myservice1 uses dynamically allocated port (for example if you run it on top of Kubernetes or Nomad).
You can also discover service by contacting Consul directly with consul template, but I think that might be inconvenient for your use case.
Hope this helps.