Newbie question: automatically forward query to all datacenters?

I am like three days old/new to consul. Say I have two data centers separated across WAN - sjc and nyc. And I want to be able to do a dns SRV query in sjc for a service thats registered in nyc. But i dont know exactly that the service is in nyc, so I dont want myself to to do a query to each data center one by one - can consul do a local dc lookup and if that fails just query all other DCs ?

As a “hack” I tried configuring both the sites as a single DC and configured wan join on the servers, it joined all fine, and I expected that within a data center all the servers will sync the services even if its over wan gossip, but that doesnt seem to happen.

Rgds,
Gopa.

Sounds like a Jobs for failover with prepared queries:

Thanks. Yes I saw the prepared query section where I can specify an order of DCs to forward the query to. So we cant achieve the same with the standard DNS / SRV lookup ?

Rgds,
Gopa.

Hi @gopakumarce ,

Prepared Queries support both A and SRV record DNS lookups. See https://www.consul.io/docs/agent/dns#prepared-query-lookups for more info.