Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Register
    • Login
    Introducing Netgate Nexus: Multi-Instance Management at Your Fingertips.

    Frequent Unbound restarts with pfsense+ 25.11.1

    Scheduled Pinned Locked Moved DHCP and DNS
    38 Posts 5 Posters 3.8k Views 5 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      markster @SteveITS
      last edited by

      @SteveITS Yes. correct.
      I just observed that in General Log.
      My Mac connected directly to SG-5100 port has static IP. However, when it goes to sleep and wakesup pfsense recongnises that as "NEW" IP and forces the reload of packages. This included UPS and DNS in my case.
      Even if your DNS is listining on localhost and outgoing interfaces is set to WAN it will perform a restart. This is causing DNS to stop and start.
      I dont know the reasons behind the "why" but it just does it so I hope people will be aware. I find it strange that pfsense is doing it.

      SteveITSS GertjanG 2 Replies Last reply
      Reply Quote 0
      • SteveITSS
        SteveITS Galactic Empire @markster
        last edited by

        @markster yep that is the classic reason. The interface is going down and up. If you put a switch in between, that will resolve this.

        To upgrade, select your branch in System/Update/Update Settings. When upgrading, allow 10-15 minutes to reboot, or more depending on packages, CPU, and/or disk speed.
        Only install packages for your version of pfSense.
        Upvote 👍 helpful posts!

        1 Reply Last reply
        Reply Quote 0
        • bmeeksB
          bmeeks
          last edited by

          @markster, you could also check to see if there is an option within your Mac OS to disable sleep for the network port. That option exists for Windows, but I'm not sure about Mac (but I suspect there is such a setting).

          As stated by others above, the services restart is caused by pfSense seeing the network interface physically go down and then come back as your connected Mac is causing a link-down event (same thing as unplugging the network cable) when it enters sleep mode and then later wakes up.

          1 Reply Last reply
          Reply Quote 0
          • GertjanG
            Gertjan @markster
            last edited by

            @markster said in Frequent Unbound restarts with pfsense+ 25.11.1:

            I dont know the reasons behind the "why" but it just does it so I hope people will be aware. I find it strange that pfsense is doing it.

            pfSense ?
            Take any OS, the one from Redmond, all Linux branches, FreeBSD, and so on.
            Processes that use network interfaces on these systems receive a network event when the interface changes state. Most of them handle it with a 'restart'.
            Why a brutal 'restart' ? Probably because there are reasons to do so, ask the programmers ^^ Some kind of internal reload might do just fine. Afaik, postfix does this, and bind (world's biggest DNS server) does so.

            As already said above, I protect all my 'expensive' pfSense network ports by inexpensive switches.
            Nice side effect : pfSense interfaces never go down.

            No "help me" PM's please. Use the forum, the community will thank you.

            M 1 Reply Last reply
            Reply Quote 0
            • M
              markster @Gertjan
              last edited by

              @Gertjan Tried it with the GS308T I had around and indeed that solved the issue.

              M 1 Reply Last reply
              Reply Quote 1
              • M
                markster @markster
                last edited by

                This post is deleted!
                1 Reply Last reply
                Reply Quote 0
                • G
                  GlennNZ
                  last edited by

                  Same symptom here, different trigger: traced to an unconditional system_hosts_generate() in rc.newwanip

                  pfSense Plus 26.07, pfBlockerNG 3.2.17_1 (DNSBL in Python mode, about 5.9M domains), Kea DHCP.

                  My ISP gives a 1800 s DHCP lease with renewal at 900 s. Every renewal returns the same IP, but each one runs rc.newwanip and Unbound reloads in place: same PID, log line Restart of unbound. With pfBlockerNG in Python mode, the module takes about 7 s to re-initialise. During that time no queries are answered, and afterwards the cache is empty. This happens 96 times a day.

                  Trace:

                  The IP-change block in /etc/rc.newwanip (line 239, which contains services_unbound_configure()) is correctly skipped. /var/db/em0_cacheip matches the current IP and there is no /tmp/wan_upstart4.
                  However, line 153 calls system_hosts_generate() unconditionally on every run.
                  system_hosts_generate() (system.inc:711) → unbound_hosts_generate() → unbound_control("reload") (unbound.inc:1150). The reload runs whether or not host_entries.conf changed.
                  Binding Unbound to selected interfaces does not help on this path. That check lives in services_unbound_configure(), and this path does not call it. My Network Interfaces setting already excludes WAN and “All”.

                  This may also explain the link up/down case earlier in this thread, if rc.newwanip runs for those interfaces. I haven’t tested that.

                  Local workaround (System Patches, strip 1, base /): reload only when the host entries actually change.

                  --- a/etc/inc/unbound.inc
                  +++ b/etc/inc/unbound.inc
                  @@ -1144,8 +1144,17 @@
                   // Generate hosts and reload services
                   function unbound_hosts_generate() {
                  +	global $g;
                  +	$hostfile = "{$g['unbound_chroot_path']}/host_entries.conf";
                  +	$oldhash = file_exists($hostfile) ? md5_file($hostfile) : '';
                  +
                   	// Generate our hosts file
                   	unbound_add_host_entries();
                   
                  -	// Reload our service to read the updates
                  +	// Local patch: reload only if the host entries changed. Avoids a full
                  +	// Unbound + pfBlockerNG reload on every same-IP WAN DHCP renewal.
                  +	clearstatcache();
                  +	if (($oldhash !== '') && (@md5_file($hostfile) === $oldhash)) {
                  +		return;
                  +	}
                   	unbound_control("reload");
                   }
                  

                  Suggested upstream fix: add the same unchanged-file check in unbound_hosts_generate(), or move the system_hosts_generate() call in rc.newwanip inside the IP-changed block.

                  GertjanG 1 Reply Last reply
                  Reply Quote 0
                  • GertjanG
                    Gertjan @GlennNZ
                    last edited by Gertjan

                    @GlennNZ

                    I totally understand you want to skip process restarting when 'nothing changed'.

                    My unbound (Resolver) restart daily at :

                    2026-11-02 00:45:26.099658+01:00 	unbound 	43522 	[43522:0] info: start of service (unbound 1.26.1).
                    

                    every day at 00:45, and that's probably because pfBlocker does it's thing.

                    My pfSense WAN uses DHCPv4.
                    The DHCPv4 server is my upstream ISP router.
                    My ISP (upstream router) has my pfSense renew it's DHCPv4 lease every 43200 seconds or 12 hours.

                    image.jpeg

                    When I compare the pfSense DHCPv4 WAN event (lease renewal) (always the same IPv4 of course, as I've "MAC-locked" it in the ISP router) with the moment unbound restarts, then I notice that unbound doesn't get restarted when the DHCPv4 event happens.
                    For me, the logic "When a new WAN IP (lease) is the same as the old WAN IP (lease), do nothing" seems to work fine.
                    Yours does.
                    So, what's different ?

                    Does your dhclient has to try many times ?
                    For example, half way during the total lease duration, de DHCPv4 client asks for a renewal.
                    When that doesn't work out, it repeats the request many times.
                    After many failures, it will 'reset' the WAN interface.
                    This is just an example.

                    Btw : I use Plus also, 26.07, and pfBlockerNG 3.2.17_1 (with about 100 k DNSBL, not millions) - Python mode as that is the standard.
                    Kea also.

                    And you know it, we know it, everybody knows it, except your ISP : 900 seconds for an IPv4 renewal is pretty sick. I guess you didn't picked them for that behavior 😊
                    I consider my '12 hours' on the short side.

                    No "help me" PM's please. Use the forum, the community will thank you.

                    1 Reply Last reply
                    Reply Quote 0
                    • G
                      GlennNZ
                      last edited by

                      You’ve found the gap in my explanation, thanks. The “same IP, do nothing” logic does exist: in pfSense-dhclient-script, a RENEW with an unchanged address leaves changes="no" and rc.newwanip isn’t signalled. Mine was signalled on every renewal. rc.newwanip does call system_hosts_generate() unconditionally, but that only matters if it runs, and I hadn’t asked why it was running.

                      It wasn’t retries. The log shows one DHCPREQUEST, a DHCPACK 44 ms later, then RENEW, with no PREINIT or interface reset. It wasn’t lease length either: my second WAN on the same box renews every 150 s and never triggered rc.newwanip. And yes, 900 s is short; it’s what the ISP hands out.

                      The difference was an Alias IPv4 address in my WAN’s DHCP client configuration, left over from setting up access to my bridged modem’s management page. In the script, the block that re-adds the alias sets changes="yes" on every renewal, even when nothing has changed, and it logs nothing. So the chain was:

                      DHCP alias on WAN → rc.newwanip on every renewal (every 900 s) → system_hosts_generate() → Unbound reload → pfBlockerNG Python module reinitialises with about 5.9M domains → about 7 s with no DNS answers and an emptied cache.

                      My second WAN also has an extra address, but as a Firewall Virtual IP rather than a DHCP alias, and it never triggered this. Modem access already ran through a separate Virtual IP on the WAN, so the alias wasn’t needed.

                      Test: I cleared the alias at 14:44. rc.newwanip ran once for that Apply, and has not run on the [N] renewals since ([times]). The filter reloads stopped with it.

                      Please disregard the unbound.inc patch I posted earlier: it only hid a symptom, and removing the alias looks like the real fix. It’s still applied here, so I can’t yet say Unbound stays quiet without it. I’ll revert it and confirm.

                      Your system behaves correctly because, I’d guess, you have no DHCP alias on WAN. Can you confirm? Anyone wanting to reproduce this can set one on a DHCP WAN and watch for rc.newwanip at each renewal.

                      I think this is a small bug in the script: re-adding an unchanged alias shouldn’t count as a change. I’ll open a Redmine report unless someone knows of an existing one.

                      GertjanG 1 Reply Last reply
                      Reply Quote 0
                      • GertjanG
                        Gertjan @GlennNZ
                        last edited by

                        Thanks for the feedback.

                        @GlennNZ said:

                        you have no DHCP alias on WAN. Can you confirm?

                        What is a "DHCP alias on WAN" ?

                        My pfSense WAN gets an RFC1918 from my upstream ISP router (192.168.10.4 - gateway ISP router 192.168.10.1).
                        My 'real' WAN IP, the one my ISP router gets, is semi static, as a company I can have a IPv4 that 'never' changes.
                        I do use a DDNS setup so I have a host name avaible that points to this WAN IPv4, so I can reach my pfSense network with VPN.

                        @GlennNZ said:

                        pfBlockerNG Python module reinitialises with about 5.9M domains

                        Be ware : most of these "5.9 M" listed host names (DNSBL) don't probably exist anymore. All it does is making unbound restart slower every time ... so it's a trade off.

                        No "help me" PM's please. Use the forum, the community will thank you.

                        1 Reply Last reply
                        Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • First post
                          Last post
                        Copyright 2026 Rubicon Communications LLC (Netgate). All rights reserved.
                        Privacy Policy · Cookie Policy