ubuntu - ubuntu中超过3个DNS服务器

标签 ubuntu dns glibc resolver resolv

我需要在“/etc/resolv.conf”中配置超过 3 个 DNS 服务器。
据 man 说,它不受支持,所以我必须重新编译 glibc

Up to MAXNS (currently 3) name servers may be listed, one per line. If there are multiple servers,
the resolver library queries them in the order listed. If no nameserver entries are present, the default is to use the name server on the local machine. (The algorithm used is to try a name server, and if the query times out, try the next, until out of name servers, then repeat trying all name servers until a maximum number of retries are performed.)


我改变了常数 MAXNSresolv/bits/types/res_state.h我编译如下:
mkdir glibc-build
cd glibc-build
../glibc-(version of glibc)/configure --prefix=/usr/local/lib/glibc-testing --with-tls --enable-add-ons=nptl
make
make install
我尝试 ping 一些站点,并在 Wireshark 的帮助下尝试查看它正在处理哪些服务器。服务器仍然寻址前三个地址。
我还看到文件/usr/include/x86_64-linux-gnu/bits/types/res_state.h没有改变。
问题是什么?

最佳答案

--prefix=/usr/local/lib/glibc-testing构建 glibc 以安装到该目录层次结构中,因此它将与系统的其余部分隔离。这是一件好事,因为 MAXNS更改是一个非常剧烈的 ABI 中断,因此需要重建相当多的程序。 make install通常在中途崩溃 --prefix=/usr ,留下一个不再可用的系统。上游 glibc 也不支持 Debian 样式的多架构目录( /usr/include/x86_64-linux-gnu/usr/include )。
无论如何,要以适合包含在上游 glibc 中的方式增加受支持的名称服务器的数量,需要执行以下步骤:

  • 停止使用 struct __res_state 中的每个名称服务器文件描述符(nssocks 数组)在 resolv/res_send.c . stub 解析器只保持一个套接字打开,因此无论如何使用数组是没有意义的。
  • 增强内部struct resolv_conf除了搜索列表条目之外,还可以跟踪名称服务器。
  • 更新向后兼容匹配代码以检查 _res 中的名称服务器更改(应用程序可以直接写入 _res ,在这种情况下应该使用这些名称服务器)。这与搜索列表代码平行。
  • 调整resolv/res_send.c中的实际DNS客户端代码使用所有名称服务器(不仅仅是 struct __res_state 中的那些)。

  • 这是一个重要的贡献,所以它需要 FSF copyright assignment .

    关于ubuntu - ubuntu中超过3个DNS服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64047757/

    相关文章:

    winapi - VB6 从 IP 查找主机名,指定 DNS 服务器

    c++ - libstdc++.so.6 : version GLIBCXX_3. 4.20 未找到

    ubuntu - 在 Ubuntu 中安装 Openstack 时出错

    ubuntu - 通过 cURL 发送 Pushkit 通知 - curl : (60) SSL certificate problem: unable to get local issuer certificate

    c++ - 二进制文件和跨平台兼容性

    c - 如何在 debian/ubuntu 上编写系统调用

    azure - 无法通过自定义子域访问 AKS 应用程序

    javascript - http ://and//之间的区别

    c++ - 需要帮助解决 NXP Linux 上的 std::thread::join() 问题

    c - glibc和相同代码的性能差异