使用resolv.h的名称解析器与IPv6 [英] Using the name resolver of resolv.h with IPv6

查看:203
本文介绍了使用resolv.h的名称解析器与IPv6的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写或修改执行名称解析的程序,需要
良好的进程控制。所以我不使用 getaddrinfo(),我更深入
并使用 res_query() / res_send() / etc in resolv.h ,在解析器(3)中记录了



虽然没有记录,但是设置解析器的常用方法是
update _res.nsaddr_list 。但是在resolv.h中定义的这个数组存储
struct sockaddr_in ,即仅IPv4地址。 (IPv6地址
struct sockaddr_in6 ,一个独立于家庭的系统将使用 struct sockaddr 。 p>

我正在寻找一种方式(最好是便携式,至少在
各种Unix中)来告诉 _res 我也想要IPv6地址。



显然,很久以前,在FreeBSD中有一个 _res_ext 这个
的能力,但是在最近的FreeBSD 7( grep
_res_ext /usr/include/resolv.h
中找不到任何东西),我找不到它。您仍然可以找到
使用它的代码(尝试自己

感谢Alnitak,我注意到现在显然是 _res._ext

code>而不是 .res_ext 。我不知道这些事情是如何记录或宣布的......我不知道如何便携式 _res._ext 是。我可以在Debian和FreeBSD上找到它。似乎有几个程序使用它。

解决方案

Stéphane - 如果你的 resolv.h 不包括对 sockaddr_in6 的任何支持,那么这表明在您的特定O / S上,解析器本身不支持IPv6传输。



我在这里检查过我的一些系统:




  • MacOS X 10.5.6 - 支持BIND 9库,它有一个 res_setservers()函数,它可以采用IPv6地址,不需要$ code> _res._ext 扩展名。


  • CentOS 5.2 - 具有 _res._ext 虽然在 resolv.conf 的手册页中没有提到IPv6,除了有一个设置可以告诉解析器返回AAAA记录,然后再查找<$ c $的A记录c> gethostbyname()。




编辑 - 同样,表明,FreeBSD 7.0(见标签 FREEBSD_7_0_0_RELEASE )也支持 res_setservers()从Bind 9。


I write or modify programs which perform name resolution and need a good control of the process. So I do not use getaddrinfo(), I go deeper and use res_query() / res_send() / etc in resolv.h, documented in resolver(3).

Although not documented, the common way to set the resolver used is to update _res.nsaddr_list. But this array, defined in resolv.h, stores struct sockaddr_in, that is IPv4 addresses only. (IPv6 addresses are struct sockaddr_in6, a family-independant system would use struct sockaddr.)

I'm looking for a way (preferrably portable, at least among the various Unix) to tell _res that I want also IPv6 addresses.

Apparently, a long time ago, there was in FreeBSD a _res_ext with this ability but I cannot find it anymore in a recent FreeBSD 7 (grep _res_ext /usr/include/resolv.h finds nothing). You can still find code which uses it (try yourself with Google Codesearch).

Thanks to Alnitak, I noticed it is apparently now _res._ext and not .res_ext. I wonder where these sort of things are documented or announced... I have no idea how portable _res._ext is. I can find it on Debian and FreeBSD. It seems there are few programs which use it.

解决方案

Stéphane - if your resolv.h doesn't include any support for sockaddr_in6 then that suggests that on your particular O/S the resolver does not itself support IPv6 transport.

I've checked some of my systems here:

  • MacOS X 10.5.6 - supports the BIND 9 library, which has a res_setservers() function which can take IPv6 addresses, no _res._ext extension.

  • CentOS 5.2 - has the _res._ext extension, although there's no mention of IPv6 in the man page for resolv.conf except that there's a setting to tell the resolver to return AAAA records before looking for A records for gethostbyname().

EDIT - also, the CVS repository for FreeBSD suggests that FreeBSD 7.0 (see tag FREEBSD_7_0_0_RELEASE) does also support res_setservers() from Bind 9.

这篇关于使用resolv.h的名称解析器与IPv6的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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