Showing posts with label pfSense. Show all posts
Showing posts with label pfSense. Show all posts

Thursday, October 15, 2026

Why Your Docker Containers Can't Resolve DNS: Fixing pfSense Unbound Timeouts

Fixing Periodic Docker Webhook Drops Caused by pfSense DNS Resolver (Unbound) Freezes

A comprehensive root cause analysis and step-by-step hardening guide for containerized services behind reverse proxies.

If you run containerized uptime monitors, alert dispatchers, or reverse-proxy stacks on a local server, you might run into an issue where outgoing notifications (such as Discord or Slack webhooks) suddenly stop firing. Inspecting the container logs often reveals failures like getaddrinfo ENOTFOUND or EAI_AGAIN.

A quick restart of the pfSense DNS Resolver (Unbound) usually restores connectivity immediately, but when this happens repeatedly every week or two, the root issue lies directly within how Unbound is processing queries.

Root Cause Analysis: What the Logs Show

Analyzing live Unbound logs when resolution drops reveals two hidden bottlenecks that interact to freeze the resolver service:

1. Excessive Debug Logging (Log Level ≥ 2)

What happens: The resolver writes dozens of granular trace messages (cache memory operations, module target iteration, module state transitions) per millisecond for every outbound query.

Why it breaks things: Disk and syslog I/O cannot keep up with high-frequency network queries. Unbound's single-threaded event loop blocks on write calls, causing incoming UDP DNS queries to time out and drop.

2. Iterative Root Recursion & Subquery Exhaustion

What happens: In pure resolver mode, pfSense manually walks every level of the global DNS tree (root . → TLD .com → authoritative nameservers → CNAME records) while validating multi-tiered DNSSEC cryptographic trust chains.

Why it breaks things: When any authoritative intermediate nameserver experiences packet loss or delays a response, Unbound logs event:module_event_noreply. The subqueries remain waiting in memory, worker threads pile up, and the service stops answering local LAN and Docker requests entirely.

Step-by-Step Fixes and Rationale

Step 1: Lower Logging Verbosity

  • Go to Services > DNS Resolver > Advanced Settings.
  • Set Log Level to Level 0 (or Level 1).
  • Click Save and Apply Changes.

Why we do this: Eliminates continuous disk write contention and prevents syslog thread blocking. Unbound can process thousands of lookups in memory without pausing to flush trace lines to the firewall storage.

Step 2: Enable DNS Query Forwarding & Disable Redundant DNSSEC

  • Go to Services > DNS Resolver > General Settings.
  • Check Enable Forwarding Mode under DNS Query Forwarding.
  • Uncheck DNSSEC.
  • Click Save and Apply Changes.

Why we do this: Instead of pfSense querying 5 to 10 authoritative servers across the globe for every lookup, it delegates resolution to high-speed upstream anycast servers (Cloudflare, Google). These enterprise resolvers already validate DNSSEC and maintain massive global caches, drastically cutting query response times and bypassing subquery lockups completely.

Step 3: Define Upstream Resolvers and Disable ISP Overrides

  • Go to System > General Setup.
  • Add reliable upstream IPs under DNS Server Settings (e.g., 1.1.1.1 and 8.8.8.8), explicitly selecting your WAN Gateway.
  • Uncheck DNS Server Override.
  • Click Save.

Why we do this: Explicit gateway binding ensures DNS traffic always routes directly out of the active internet link. Unchecking "DNS Server Override" prevents your local ISP from pushing slower or less reliable DNS addresses during WAN DHCP lease renewals.

Step 4: Disable Dynamic DHCP Lease Registration

  • Go to Services > DNS Resolver > General Settings.
  • Scroll to the bottom and ensure DHCP Registration (Register DHCP leases in the DNS Resolver) is unchecked.
  • Leave Static DHCP checked if you map local servers statically.
  • Click Save and Apply Changes.

Why we do this: This is the most common cause of recurring Unbound crashes in pfSense. When enabled, pfSense completely reloads the Unbound service every single time a phone, laptop, or IoT device requests or renews an IP lease. On active networks, these constant restarts corrupt the cache or deadlock the process.

Step 5: Add Container-Level DNS Fallbacks

In your Docker Compose file, explicitly define upstream resolvers under the service definition:

services:
  monitoring-service:
    image: louislam/uptime-kuma:latest
    container_name: uptime-kuma
    restart: always

    # Provide direct DNS resolvers to ensure alerting never hangs on LAN DNS
    dns:
      - 1.1.1.1
      - 8.8.8.8

    networks:
      - web

Why we do this: Establishes defense-in-depth. If your internal router is ever rebooted, updated, or temporarily unreachable, your alert monitoring containers can still resolve external APIs and dispatch critical downtime notifications without interruption.

Expected Outcome: By turning off the DHCP restart loop, offloading recursive lookups to fast upstream forwarders, and removing excessive disk logging, Unbound maintains a lean in-memory cache and stops locking up. Internal hosts and containers will consistently resolve names without requiring manual firewall intervention.

Monday, July 13, 2026

pfSense Useful SSH Commands

 


Get user creation dates:

bzgrep "Successfully created user" /var/log/system.log* | awk '{print $1, $2, $3, "-> User Created:", $NF}' | uniq


Get OpenVPN connections per user (newest at bottom):

bzgrep -E "user '.*' authenticated" /var/log/openvpn.log*



Wednesday, May 13, 2026

Solving Asymmetric Routing: Accessing LAN Devices with Misconfigured Gateways

 

Issue:

Managed switch at 192.168.1.2 was reachable via ARP but "filtered" on all ports during Nmap scans over OpenVPN. The switch had a misconfigured Default Gateway (.254 instead of .1.1), causing a routing dead-end where the switch could receive packets but couldn't route replies back to the 10.8.0.0/24 VPN subnet.



Temporary Resolution (VPN):

Implemented a Hybrid Outbound NAT rule in pfSense on the LAN interface. This masqueraded VPN traffic as coming from the LAN interface IP (192.168.1.1), tricking the switch into responding to a local address. Once GUI access was gained, the System Default Gateway was corrected to 192.168.1.1 and saved to flash.



Resolution:

Update switch gateway to correct gateway. In this case it was .254 to .1


πŸ‘½

Tuesday, November 14, 2023

pfSense - Not Resolving Hostnames to IP Addresses?

 


Intro:

For a while this has been bugging me. You should be able to ping a hostname on the local network and it should return the device's IP address. It's working for some hosts but not all. This is under Windows 10 Enterprise or Pro.

"ping orangepizero3" should return 192.168.2.226 but the ping command is stating "Ping request could not find host orangepizero3. Please check the name and try again.".




Fix:

Call up your pfSense web admin portal.

Navigate to "Services --> DNS Resolver".

Scroll all the way down and at the bottom enable the following two settings:
  • DHCP Registration
  • Static DHCP


The page will reload, click on "Apply" in green.



Flush the DNS resolver on your machine.

ipconfig /flushdns


Try pinging the host again.




Side Notes:

Google Chrome loves to not work properly on many levels. For the example above I'm finding that it doesn't even attempt to look up "orangepizero3" before returning "Address not found...".


If I call up "http://orangepizero3/admin" in a normal or private Chrome Window, I get the same error. 
  • CTRL + Reload doesn't do jack.
  • Clearing the DNS cache at "chrome://net-internals/?#dns" doesn't do shit either.

However if call it up in FireFox in either a normal page or private page, it loads the Pi-hole page after a second or two of thought. Subsequent lookups are even faster due to its caching.

At a loss with Chrome.



πŸ‘½

Sunday, April 17, 2022

pfSense - Delete Expired DHCP Leases Manually

 

 

Intro:

Here's a quick way to remove/purge all expired DHCP leases from pfSense if you don't feel like waiting until pfSense reclaims them.

 This is also super helpful if an IP address is mistakenly assigned to the wrong MAC via DHCP and you then need to assign it as static to a different MAC. If you're making quick changes to the DHCP server you'll find a use for this.

 

Fix:

  1. Log into your pfSense box.
  2. Top right, click on "Diagnostics" ➡ "Edit File".
  3. Load "/var/dhcpd/var/db/dhcpd.leases".
  4. Select the blocks that you need to remove. Each block of data begins with the word "leases" and ends with a curly brace, "}".
  5. When done editing the file directly click on "Save" near the top left of the edit box.

 

Extras:

There may be another file with the same name but with a tilde "~" sign after it. This file indicates that it is a backup of the original "dhcpd.leases" file. To be sure you've changed it in all necessary files, go ahead and delete the leases from this backup file as well or make life easy and just copy the "dhcpd.leases" content over to the "dhcpd.leases~" file and save.
 
DHCPv6 Leases can also be deleted but the file names are slightly different as seen below, however the files reside in the same folder as the IPv4 files:
 

IPv6:

  • dhcpd6.leases
  • dhcpd6.leases~

IPv4:
  • dhcpd.leases
  • dhcpd.leases~


πŸ‘½

Friday, March 4, 2022

pfSense - Get Memory Module Manufacturer, Part Number, Serial Number, Memory Speed, and Voltage - All Without SSH



Intro:

I found this useful when trying to order memory for a new pfSense network appliance. I had purchased Crucial memory in the past however I've ordered way to much RAM for client machines that it was hard to differentiate between the models. To be 100% sure that I reordered the correct module, I was able to use the command below to grab the exact model number of the RAM stick used in this particular appliance.

Start Here:

1.) Call up your pfSense box and login.

2.) Click on 'Diagnostics' --> 'Command Prompt'

Diagnostics Menu


3.) In the section that says, 'Execute Shell Command' type the following, 'dmidecode --type 17' and click on 'Execute'.

Execute Shell Command

See this image for the syntax


4.) In the section below you can see the manufacturer, part number, serial number, memory speed, and voltage.

Results of dmidecode


Memory Photo by Possessed Photography on Unsplash

πŸ‘½