Bug 291790 - libc stub resolver no longer works without /etc/resolv.conf
Summary: libc stub resolver no longer works without /etc/resolv.conf
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 16.0-CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-18 23:07 UTC by wbe
Modified: 2026-02-13 12:44 UTC (History)
3 users (show)

See Also:
des: mfc-stable15+
des: mfc-stable14+
des: mfc-stable13-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description wbe 2025-12-18 23:07:27 UTC
This appears to be an "upgrade from 14.3 to 15.0" issue.

In 14.3-RELEASE-p7 (actually pretty much any 14.*), local-unbound did not need
/etc/resolv.conf.  Indeed, the file /etc/resolv.conf.no specifically says:

"#not when running name server on localhost; better to have no file"

However, in 15.0-RELEASE-p1, I find that /etc/resolv.conf needs to exist.  Indeed, 15.0's "man local-unbound" says:

"To use a locally running Unbound for resolving put

           nameserver 127.0.0.1

     into resolv.conf(5)."

In 15.0 without /etc/resolv.conf, name resolution fails.

When upgrading from 14.3 (which didn't have resolv.conf and worked fine) to 15.0 (which needs it to work), the file was not created.  The first symptom I encountered during the upgrade, however, was something else entirely: "pkg upgrade -f" (and even just "pkg update") didn't work. It took me a while to figure out what the actual problem was (i.e., not pkg or its configuration).  [More on that in a separate bug report I'll submit next.]

Creating /etc/resolv.conf made things work again.

I see this as a 1-time transition to 15.0 issue.  Submitting this documents the problem.
Comment 1 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2025-12-19 00:00:45 UTC
FreeBSD has always required an /etc/resolv.conf.  I don't know where you got the idea that it didn't.  If you are using the local_unbound service, running `service local_unbound setup` will create one for you.
Comment 2 wbe 2025-12-19 01:55:45 UTC
> (In reply to Dag-Erling Smørgrav from comment #1)
> FreeBSD has always required an /etc/resolv.conf.  I don't know where you got the idea that it didn't.
[Foo, my previous reply seems to have been discarded.  Trying again...]
From:

1) (as I said in the description) the first line of /etc/resolv.conf.no which said:

"#not when running name server on localhost; better to have no file"

2) the fact that my GENERIC system has been working just fine without an /etc/resolv.conf since at least as far back as 12.0-RELEASE-p1 in 2019, and

3) Upon looking into this further, I see the date on resolv.conf.no is April 25, 2012 (which is most likely the date I ceased having a resolv.conf), but it looks like I didn't switch to local-unbound until 2014, so I'm not sure what to think.  

What is clear is that, no, resolv.conf hasn't always been required for name resolution.  I note that man resolv.conf still says:
"    On a normally configured system, setting this file manually should not be
     necessary.  The only name server(s) to be queried will be on the local
     machine or automatically configured using DHCP or a similar mechanism,
     the domain name is determined from the host name, and the domain search
     path is constructed from the domain name.
"
which could be interpreted as either "file not required" or "the default file provided shouldn't need to be changed".

Maybe that means it worked, but via a resolver other than the local named or unbound?  No DHCP, though.

I'm happy leaving this bug report closed.  It's here if anyone else comes looking.
Comment 3 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2025-12-19 08:38:41 UTC
1. Your /etc/resolv.conf.no was not created or used by FreeBSD and we cannot be held responsible for any (mis)information it contains.

2. The only changes in libc's resolver code between 14.0 and 15.0 is the removal of debugging code.  In fact, the last time the resolver code saw substantial change was in FreeBSD 12.0.

3. In the absence of /etc/resolv.conf, applications that rely on libc will attempt to connect to a DNS server on INADDR_ANY and IN6ADDR_ANY.  Whether or not that succeeds depends on how your IP stack and your nameserver are configured.

4. In addition, libc will not attempt to use EDNS(0) unless explicitly told to do so by /etc/resolv.conf, meaning that DNSSEC and anything that relies on it (like SSHFP records) will most likely not work.

5. Applications that provide their own resolver library may or may not have useful defaults.  The only way to ensure consistent and reliable operation is to provide an /etc/resolv.conf that everyone understands.
Comment 4 wbe 2025-12-19 09:11:53 UTC
(In reply to Dag-Erling Smørgrav from comment #3)
> 1. Your /etc/resolv.conf.no was not created or used by FreeBSD and we cannot be held responsible for any (mis)information it contains.
OK.  If I wrote that line as a note to myself, it would have been because I saw it stated in pretty much those words somewhere, but as that was 2012, I've long since forgotten where.

> 3. In the absence of /etc/resolv.conf, applications that rely on libc will attempt to connect to a DNS server on INADDR_ANY and IN6ADDR_ANY.  Whether or not that succeeds depends on how your IP stack and your nameserver are configured.
Good to know, and you're agreeing yes, name resolution can work in the absence of /etc/resolv.conf.  I also note that the man page for resolv.conf says that the resolver to use can also come from DHCP and other sources.

> 4. In addition, libc will not attempt to use EDNS(0) unless explicitly told to do so by /etc/resolv.conf, meaning that DNSSEC and anything that relies on it (like SSHFP records) will most likely not work.
Haven't tried to use that, so I make no claim that that used to work.

> The only way to ensure consistent and reliable operation is to provide an /etc/resolv.conf that everyone understands.
Sounds good, and now I've got one.  If anyone else runs into this problem, point them to this page.
Comment 5 wbe 2025-12-19 10:45:57 UTC
(In reply to Dag-Erling Smørgrav from comment #3)
>2. The only changes in libc's resolver code between 14.0 and 15.0 is the removal of debugging code.  In fact, the last time the resolver code saw substantial change was in FreeBSD 12.0.
Actually, I guess I will say one thing more...
Aside from the point that having resolv.conf is a good thing, there's still an issue.  Given that:
1) it had been working for years,
2) moments later, under 15.0-RELEASE-p1, it consistently didn't, and
3) any change at all was made to that code, even if the change should have been innocuous,
it's hard to avoid concluding that an unintended change may have crept in unless there's an alternative explanation, such as local-unbound previously responded to the INADDR_ANY and now doesn't (which I would think unlikely).
Comment 6 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2025-12-19 12:55:27 UTC
There have been no functional changes to the libc resolver since FreeBSD 12.

Connecting to INADDR_ANY no longer works.  I am trying to find out if that was intentional.  I suspect it wasn't, as connecting to IN6ADDR_ANY still works.

Regardless of the above, running without /etc/resolv.conf may have worked in the past but has never been supported.
Comment 7 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2025-12-19 13:00:04 UTC
The change was indeed intentional and is documented in the FreeBSD 15.0 release notes (search for “INADDR_ANY”).  So the only remaining issue is that it still works for IPv6 (IN6ADDR_ANY).
Comment 8 wbe 2025-12-19 18:01:38 UTC
Chiming in, since I opened this report ...

So, the original issue I reported here (that name resolution broke for me when upgrading from 14.3 to 15.0) is now understood (operation in the absence of /etc/resolv.conf changed), and the change was intentional.  Excellent.  Thank you.
Comment 9 Dag-Erling Smørgrav freebsd_committer freebsd_triage 2026-01-31 12:19:13 UTC
Reopening because:

- https://reviews.freebsd.org/D54306, which disables connecting to IN6ADDR_ANY, was committed
- I've posted https://reviews.freebsd.org/D55011, which changes the fallback to the loopback address, for review
Comment 10 commit-hook freebsd_committer freebsd_triage 2026-01-31 17:54:17 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1538284a5fddfce546db678cb873b7edc6adb9ed

commit 1538284a5fddfce546db678cb873b7edc6adb9ed
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-01-31 17:52:53 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-01-31 17:52:53 +0000

    libc/resolv: Switch default to loopback address

    If no resolver configuration was found, we would fall back to INADDR_ANY
    and IN6ADDR_ANY.  This made sense when it was first written thirty or
    forty years ago but not today, especially since connecting to INADDR_ANY
    or IN6ADDR_ANY is no longer supported.  Switch to the loopback address
    and simplify the code.

    Note that (as the pre-existing comment in the code states) running
    without a resolver configuration is not really supported.  Still, if
    we're going to have a hardcoded fallback, it might as well work.

    PR:             291790
    MFC after:      1 week
    Reviewed by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D55011

 lib/libc/resolv/res_init.c | 67 ++++++++++++++++++----------------------------
 1 file changed, 26 insertions(+), 41 deletions(-)
Comment 11 commit-hook freebsd_committer freebsd_triage 2026-02-05 14:36:47 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=c137555c3f39a7defa61c53e357d83638bec8c66

commit c137555c3f39a7defa61c53e357d83638bec8c66
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-01-31 17:52:53 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-02-05 14:36:19 +0000

    libc/resolv: Switch default to loopback address

    If no resolver configuration was found, we would fall back to INADDR_ANY
    and IN6ADDR_ANY.  This made sense when it was first written thirty or
    forty years ago but not today, especially since connecting to INADDR_ANY
    or IN6ADDR_ANY is no longer supported.  Switch to the loopback address
    and simplify the code.

    Note that (as the pre-existing comment in the code states) running
    without a resolver configuration is not really supported.  Still, if
    we're going to have a hardcoded fallback, it might as well work.

    PR:             291790
    MFC after:      1 week
    Reviewed by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D55011

    (cherry picked from commit 1538284a5fddfce546db678cb873b7edc6adb9ed)

 lib/libc/resolv/res_init.c | 67 ++++++++++++++++++----------------------------
 1 file changed, 26 insertions(+), 41 deletions(-)
Comment 12 commit-hook freebsd_committer freebsd_triage 2026-02-05 14:37:48 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=6b0a4d67a952e999c39ee21a5e50122b13a6d391

commit 6b0a4d67a952e999c39ee21a5e50122b13a6d391
Author:     Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2026-01-31 17:52:53 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2026-02-05 14:36:49 +0000

    libc/resolv: Switch default to loopback address

    If no resolver configuration was found, we would fall back to INADDR_ANY
    and IN6ADDR_ANY.  This made sense when it was first written thirty or
    forty years ago but not today, especially since connecting to INADDR_ANY
    or IN6ADDR_ANY is no longer supported.  Switch to the loopback address
    and simplify the code.

    Note that (as the pre-existing comment in the code states) running
    without a resolver configuration is not really supported.  Still, if
    we're going to have a hardcoded fallback, it might as well work.

    PR:             291790
    MFC after:      1 week
    Reviewed by:    kevans
    Differential Revision:  https://reviews.freebsd.org/D55011

    (cherry picked from commit 1538284a5fddfce546db678cb873b7edc6adb9ed)

 lib/libc/resolv/res_init.c | 67 ++++++++++++++++++----------------------------
 1 file changed, 26 insertions(+), 41 deletions(-)