libunbound not always picking the first nameserver in /etc/resolv.conf

Paul Wouters paul at
Wed Feb 16 00:46:34 UTC 2022

On Wed, 16 Feb 2022, Jiatong Shen via Unbound-users wrote:

>   hello, I have a small question and would like to get some insights..I am using openvswitch + sflow to connect network traffic and when posting data
> openvswitch seems to not resolving address correctly. after some debugging, I find that openvswitch uses libunbound to resolve dns and sometimes dns
> resolve does not work. I check the /etc/resolve.conf file, and find that there are dns nameservers configured and one of them cannot resolve the given dns
> name (because it is local dns and is not global resolvable). but the global dns is configured after the local nameserver, so in my opinion it should have
> a higher priority. but looks like libunbound does not respect the nameserver order.
>  My question is is my observation correct? if it is correct, is there anyway I can make libunbound to use dns nameservers in the order defined in
> resolv.conf? thank you

libunbound won't use your resolv.conf at all, unless the code using
libunbound calls ub_ctx_resolvconf(ctx, "/etc/resolv.conf") before
the first query is attempted.

Note also that if your system uses systemd and has "resolve" in
/etc/nsswitch.conf, glibc bypasses resolv.conf for gethostbyname()
to talk to systemd-resolved directly, but getaddrinfo() does use


More information about the Unbound-users mailing list