Description
Is your feature request related to a problem? Please describe.
On a system with multiple network interfaces, I would like to make DNS resolution requests over a specific interface.
I have a problem similar to #14617. Consider a Linux server with 2 interfaces, primary eth0
and a backup internet connection using a LTE modem on eth1
. The system's default route is over eth0
, and in normal operation all traffic goes over that interface.
If the primary connection is unavailable, I want to be able to make certain requests from my node program over the backup connection. However, the backup connection is metered, so I don't want a systemwide failover; only specific, high-priority requests should go over the backup.
With the appropriate alternate IP routing table and rules configured, this works for TCP sockets if you set localAddress
when calling connect(opts)
and already know the destination address. However, I need a way to resolve DNS over the backup connection if necessary — and separately from the system's default resolv.conf settings.
Describe the solution you'd like
This could be accomplished similarly to the localAddress
option available to TCP sockets. (There's also bind(port, address)
available to UDP sockets.)
eg:
const dns = require('dns');
const resolver = new dns.Resolver({ localAddress: '192.168.0.x' });
resolver.setServers(['8.8.8.8']);
resolver.resolve4(…);
I think this would be as simple as calling ares_set_local_ip4
/ares_set_local_ip6
somewhere in cares_wrap.cc.
Activity