简体   繁体   English

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

[英]c-ares specifying network interface for the DNS resolves

Is there a way in which you can set the network interface to which the DNS requests can be bound to. 有没有一种方法可以设置DNS请求可以绑定到的网络接口。

We have a project which requires to use a highpriority streaming session go through one interface and all the other requests channeled through the second one. 我们有一个项目,要求使用高优先级的流会话通过一个接口,而所有其他请求则通过第二个接口进行传输。

example: setting 'eth0' so that all the ares requests will go through 'eth0' and not on 'wlan0'. 示例:设置“ eth0”,以便所有ares请求都通过“ eth0”而不是“ wlan0”。

I was not able to find any API in c-ares (in ares_init_options() API) that gives this option of setting interface. 我无法在c-ares(在ares_init_options()API中)中找到任何提供此设置界面选项的API。

Can you please let me know if there is some way to achive this or if I missed something. 您能告诉我是否有办法实现这一目标,或者我错过了一些事情。

Thanks, Arjun 谢谢阿俊

If you have a fairly new c-ares (c-ares >= 1.7.4), check out ares.h (It's the only place I've actually found it referenced). 如果您有一个相当新的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);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM