c-ares指定DNS解析的网络接口

有没有办法可以设置DNS请求可以绑定到的网络接口。

我们有一个项目需要使用高优先级流会话通过一个接口和所有其他请求通过第二个接口。

示例:设置’eth0’,以便所有bes请求将通过’eth0’而不是’wlan0’。

我无法在c-ares中找到任何API(在ares_init_options()API中),它提供了设置界面的选项。

如果有办法解决这个问题,或者我错过了什么,你能告诉我吗?

谢谢,阿琼

如果你有一个相当新的c-ares(c-ares> = 1.7.4),请查看ares.h(这是我实际发现它引用的唯一地方)。

/* These next 3 configure local binding for the out-going socket * connection. Use these to specify source IP and/or network device * on multi-homed systems. */ CARES_EXTERN void ares_set_local_ip4(ares_channel channel, unsigned int local_ip); /* local_ip6 should be 16 bytes in length */ CARES_EXTERN void ares_set_local_ip6(ares_channel channel, const unsigned char* local_ip6); /* local_dev_name should be null terminated. */ CARES_EXTERN void ares_set_local_dev(ares_channel channel, const char* local_dev_name);