How to Resolve Local Hostnames in OPNSense

My router runs OPNSense Business. I like having an open-source router, but I have a few gripes with it.

My biggest issue is that, by default, OPNsense can’t resolve hostnames on my local network.

Why can’t OPNsense resolve local hostnames? 🔗︎

For every other router I’ve owned in my life, if there’s a computer on my network named foo123 and I run ping foo123 from my main desktop, then everything just works. My desktop successfully pings foo123.

With OPNsense, I can’t ping foo123 from my desktop. OPNsense seems to not resolve local hostnames by default, and I don’t understand why.

I’ve found workarounds that improve the situation somewhat, but it’s still not perfect.

Tell Unbound to resolve local hostnames 🔗︎

Go to Services > Unbound DNS > General.

Check these options:

  • Register ISC DHCP4 Leases
  • Register DHCP Static Mappings

Check “Register ISC DHCP4 Leases” and “Register DHCP Static Mappings”in Unbound settings

Click Apply to apply the changes.

Manually specify hostnames 🔗︎

Despite configuring Unbound, I find that OPNsense still doesn’t always resolve local hosts, and I don’t know why.

In situations where I just need OPNsense to resolve, I force the mappings manually.

Choose a local domain name 🔗︎

  1. Go to System > Settings > General.
  2. Under “Domain” specify a domain name for your local network.
    • I always thought you were supposed to choose local, but the help text warns that you’re not supposed to do that.
    • I chose home.arpa, as that’s the technically correct domain for a home network, but wow is it ugly.
    • According to the IETF’s definition, the domain should actually be home.arpa. (with a trailing dot), but OPNsense rejects that as a domain and recommends home.arpa, so I’m sticking with that.
  3. Click “Save” to apply the change.

Create a static mapping for the host 🔗︎

  1. Go to Services > ISC DHCPv4 > Leases
  2. Find the host in the list of hosts that you want OPNsense to resolve.
  3. Click the + icon at the right end of the table row. This should bring you to the Static DHCP Mapping dialog.
  4. Enter a local IP address in the IP address field.
  5. Click “Save” to save the static IP mapping.

Create a manual override for the hostname 🔗︎

  1. Go to Services > Unbound DNS > Overrides.
  2. Under “Host Overrides”, click the orange “+” button to add a new override.
  3. Under “Host” enter the hostname you specified in the static mapping.
  4. Under “Domain” enter home.arpa.
  5. Under “IP address” enter the IP address you chose in the static mapping.
  6. Click “Save”.

Specifying hosts with the .home.arpa domain suffix 🔗︎

Sometimes, when OPNsense fails to resolve host foo123, it successfully resolves foo123.home.arpa, so I always try adding the domain suffix if the bare hostname doesn’t work.

I’m not sure why OPNsense needs the suffix, as the lack of domain name should make it obvious that I’m talking about a host on the local network, but the .home.arpa domain sometimes makes a difference.

Other improvements? 🔗︎

If you have suggestions for making OPNsense’s hostname resolution less brittle and more reliable, let me know in the comments.

Read My Book

I'm writing a book of simple techniques to help developers improve their writing.

My book will teach you how to:

Read Michael's Book