c-ares specifying network interface for the DNS resolves

自闭症网瘾萝莉.ら 提交于 2019-12-20 04:29:12

问题


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.

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

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.

Thanks, Arjun


回答1:


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


来源:https://stackoverflow.com/questions/7611544/c-ares-specifying-network-interface-for-the-dns-resolves

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!