I have a question regarding destination determination of DNS lookups when a machine is connected to multi network interfaces (Linux).
Intro: I am developing a Linux box which is connected to 2 (or more) networks. Each Network interface is connected to a different network (ISP) and receives (DHCP) different IP / Default Gateway and 2 DNS servers.
The box runs different network applications (clients) which are bounded to a specific interface.
For example:
Application A connects to a server via network 1 (interface 1).
Application B connects to a server via network 2 (interface 2).
I can use source based routing to control the destination interface for each Application. (In Linux with routing policy - ip rule/ ip route / etc…).
My question is regarding DNS lookups:
Linux share one resolv.conf file, both networks (1,2) DNS server are maintained in this file.
When an application uses the standard getaddrinfo() function, it uses Linux default resolving mechanism (which goes through the reolv.conf file).
This means that Application B can send its DNS queries to a DNS server which is related to network 1.
I have access to the code, I can do it manually and send a DNS query directly to a specific DNS server from my application, but this is not the preferred option.
Is there standard ways (code/or configuration) to cause DNS lookups from Application A choose network 1 DNS server and Application B choose network 2 DNS server?
Thanks