I have a Linux VM which is connected to 2 different virtual networks. Say IP-1 (in vnet-1) = 192.168.0.5/24 and IP-2 (in vnet-2) = 172.16.0.6/24. I have a DNS server (say 10.0.0.10) which returns different results based on source IP. Eg: If I search for "nginx-service" using IP-1 as source IP, I will get result for service in vnet-1 And if I search for "nginx-service" using IP-2 as source IP, I will get result for service in vnet-2.
I have some services in vnet-1, and some in vnet-2. So I want to conditionally query some domains via IP-1 and some via IP-2 (the list is fixed). Is there any way to accomplish this with existing resolvers?
I can potentially write my own DNS resolver which constructs dns query with correct source IP based on the domain to resolve. But it would be preferable if an existing resolver like coredns, or dnsmasq has this ability. I know that dig allows you o specify source IP using -b option.