C-战神指定网络接口,为能够进行DNS解析 [英] c-ares specifying network interface for the DNS resolves

查看:419
本文介绍了C-战神指定网络接口,为能够进行DNS解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有,可以在其中设置该DNS请求可以绑定到网络接口的一种方法。

Is there a way in which you can set the network interface to which the DNS requests can be bound to.

我们有这需要通过一个界面并全部通过第二个渠道的其他要求使用高优先级流会话去的一个项目。

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.

例如:设置'eth0的,让所有的战神请求将通过eth0的,而不是为wlan0

example: setting 'eth0' so that all the ares requests will go through 'eth0' and not on 'wlan0'.

我是不是能够找到C-顷任何API(在ares_init_options()API),让设置界面中选择此选项。

I was not able to find any API in c-ares (in ares_init_options() API) that gives this option of setting interface.

能否请您让我知道如果有一些方法才达到这个还是我错过了什么。

Can you please let me know if there is some way to achive this or if I missed something.

谢谢,
阿琼

推荐答案

如果你有一个相当新的C-顷(C-战神> = 1.7.4),检查ares.h(这是我唯一的地方居然发现它引用)。

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).

/* 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);

这篇关于C-战神指定网络接口,为能够进行DNS解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆