• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login
Netgate Discussion Forum
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Search
  • Register
  • Login

Different DNS forward based on subnet/VLAN?

Scheduled Pinned Locked Moved DHCP and DNS
6 Posts 3 Posters 1.0k Views
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
    MrPete
    last edited by Jan 4, 2023, 4:38 PM

    We've got multiple subnets/VLANs with differing DNS filtering requirements. (Think: opendns filter policy vs generic.) PLUS, we have a number of internal DNS host overrides.

    I can configure custom DNS by interface at the DHCP level, but doing so bypasses pfSense host overrides.

    Other than that, it appears that DNS resolution servers are configured at the System->General Setup level (or just resolved in pfSense.)

    Question: is there some kind of other feature available (a custom/advanced DNS option?) that allows DNS forwarding to be customized per-subnet, without breaking the host overrides?

    B J 2 Replies Last reply Jan 4, 2023, 11:10 PM Reply Quote 0
    • B
      bmeeks @MrPete
      last edited by bmeeks Jan 4, 2023, 11:11 PM Jan 4, 2023, 11:10 PM

      @mrpete said in Different DNS forward based on subnet/VLAN?:

      Question: is there some kind of other feature available (a custom/advanced DNS option?) that allows DNS forwarding to be customized per-subnet, without breaking the host overrides?

      I don't know of any way to accomplish that using the built-in DNS Resolver (or Forwarder) within pfSense. You can certainly accomplish it using an external DNS server for each subnet. For example, you could use a hypervisor to host as many Linux-based (or Windows, if that floats your boat 😀) DNS server virtual machines as needed. Then over in pfSense configure each DHCP scope to hand-out the proper DNS server IP address from all the guests running on the hypervisor. Of course that solution requires extra hardware and expense - and it would require duplicating your custom host/domain overrides on each of the guest virtual machine DNS servers.

      1 Reply Last reply Reply Quote 1
      • J
        johnpoz LAYER 8 Global Moderator @MrPete
        last edited by Jan 4, 2023, 11:21 PM

        @mrpete If your trying to do this all with 1 nameserver your best best prob be to use bind. When you create views with bind pretty sure it creates their own cache vs I believe unbound uses a shared cached.. But not sure if there has been any changes to that in latest versions of unbound.

        The problem that can happen when you use different filtering forwarders for different clients, if you have a shared cache.. client A asks for something that is not filtered for him, and then another client comes in and gets that via cache vs what the forwarder might return for it being filtered.

        Been meaning to do some testing of how best to accomplish this either via bind or unbound since this sort of question comes up quite a bit actually.

        But the most straight forward solution is yes is to use different nameservers (dns) for your different clients that need to use different filtering. This way your sure all those clients will only be see a cache with their filtering done. And you don't have to worry about setting up views which can be a learning curve for users new to them.

        These different NS for your different clients could all use domain override to ask say pfsense for the local resources they all should be able to resolve.

        An intelligent man is sometimes forced to be drunk to spend time with his fools
        If you get confused: Listen to the Music Play
        Please don't Chat/PM me for help, unless mod related
        SG-4860 24.11 | Lab VMs 2.7.2, 24.11

        M 1 Reply Last reply Jan 6, 2023, 7:14 PM Reply Quote 0
        • M
          MrPete @johnpoz
          last edited by MrPete Jan 6, 2023, 10:45 PM Jan 6, 2023, 7:14 PM

          @johnpoz said:

          The problem that can happen when you use different filtering forwarders for different clients, if you have a shared cache...

          Yeah, problematic, no question.

          These different NS for your different clients could all use domain override to ask say pfsense for the local resources they all should be able to resolve.

          Now THAT sounds interesting.
          As I'm quite sure you 'get', it would be a royal pain to have to configure a domain override set in each of multiple DNS servers.

          I've now examined the unbound documentation. I don't see any suggestion that it supports split cache, let alone split forwarding based on any factor of any kind. Perhaps a future-feature?

          Unbound does have tags and views configurable by many factors, including IP and more. However, those only control local responses, not forwarding.

          Here's a nice doc page explaining how to do exactly what we're discussing in bind. Bind views split both the DNS config and the cache. It's quite straightforward (assuming their info is correct; I've not tried it :-D) Bind views make it as simple as:

          view "students" {
              recursion yes;
              forward only;
              forwarders { ip; ip; ip; };
              match-clients { 192.168.10.0/24; };
              include "/etc/bind/our-local-ip.zones";
              }
          

          (in /etc/named.conf or /etc/bind/named.conf)

          Bind even supports cache controls such that (for example) a guest subnet has zero access to local client IP/name info.
          Note that (as of Bind 9.7.0), multiple views can be configured to share a cache, so the result can be made as efficient as one could expect. (attach-cache cache_name;)

          NO need for multiple nameservers. Looks like time for me to learn about using bind in pfSense :)

          J 1 Reply Last reply Jan 6, 2023, 7:23 PM Reply Quote 0
          • J
            johnpoz LAYER 8 Global Moderator @MrPete
            last edited by Jan 6, 2023, 7:23 PM

            @mrpete said in Different DNS forward based on subnet/VLAN?:

            Looks like time for me to learn about using bind

            It behooves anyone doing anything with dns to learn about bind to be honest.. ;)

            While forwarding per view might not be documented in unbound, the subject has come up multiple times and you might be able to put forward in your view, etc. But yeah until they have isolated cache for the different views - even if works and view X forwards to A, and view Y forwards to B its not a workable solution unless the views X and Y have their own cache.

            An intelligent man is sometimes forced to be drunk to spend time with his fools
            If you get confused: Listen to the Music Play
            Please don't Chat/PM me for help, unless mod related
            SG-4860 24.11 | Lab VMs 2.7.2, 24.11

            M 1 Reply Last reply Jan 7, 2023, 4:38 PM Reply Quote 1
            • M
              MrPete @johnpoz
              last edited by Jan 7, 2023, 4:38 PM

              @johnpoz said in Different DNS forward based on subnet/VLAN?:

              While forwarding per view might not be documented in unbound, the subject has come up multiple times and you might be able to put forward in your view, etc.

              Found it as an Enhancement Issue. They understand the caching implications and have no plans to implement. First raised in 2020; someone asked for an update in Nov 2022 but no reply yet ;)

              1 Reply Last reply Reply Quote 2
              6 out of 6
              • First post
                6/6
                Last post
              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.
                This community forum collects and processes your personal information.
                consent.not_received