I need to configure more than 3 DNS servers in "/etc/resolv.conf". According to man, it is not supported so I have to recompile 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.)
I changed the constant MAXNS
in resolv/bits/types/res_state.h
and I compiled as follows:
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
I tried to ping some sites and with the help of Wireshark I tried to see which servers it was addressing. The servers still addressed the first three addresses.
I also saw that the file /usr/include/x86_64-linux-gnu/bits/types/res_state.h
did not change.
What is the problem?
--prefix=/usr/local/lib/glibc-testing
builds glibc for installation into that directory hierarchy, so it will be isolated from the rest of the system. This is a good thing because the MAXNS
change is a pretty drastic ABI break, so it would require rebuilding quite a few programs. make install
typically crashes half-way through with --prefix=/usr
, leaving a system behind that is no longer usable. Upstream glibc also does not have support for Debian-syle multi-arch directories ( /usr/include/x86_64-linux-gnu
in addition to /usr/include
).
Anyway, to increase the number of supported name servers in a way that would be suitable for inclusion into upstream glibc, the following steps are needed:
struct __res_state
(the nssocks
array) in resolv/res_send.c
. The stub resolver keeps only one socket open, so it does not make sense to use an array anyway.struct resolv_conf
to keep track of name servers, in addition to the search list entries._res
(applications may directly write to _res
, in which case these name servers should be used). This parallels the search list code.resolv/res_send.c
to use all name servers (not just those in struct __res_state
).This is a non-trivial contribution, so it would need FSF copyright assignment .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.