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

    Pfsense with pihole correct configuration?

    Scheduled Pinned Locked Moved DHCP and DNS
    42 Posts 4 Posters 9.4k 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.
    • A
      agaitan026 @johnpoz
      last edited by agaitan026

      @johnpoz got it
      so on nat
      4f97188a-5a06-4e29-9212-ffeac02f5c47-image.png

      what im confused is the lan rule not sure how exactly should be
      f2ac83a1-0c18-4e27-b574-d30939dc9bf4-image.png

      that 192.168.1.89 is my pihole

      johnpozJ 1 Reply Last reply Reply Quote 0
      • johnpozJ
        johnpoz LAYER 8 Global Moderator @agaitan026
        last edited by johnpoz

        No not really... The redirect is suppose to be to loopback 127.0.0.1

        Which then you setup to ask pihole. Pihole then asks clouldflare.

        Such a setup runs into asymmetrical flow.. I have gone over this multiple multiple times. if you want to do such a redirect then you would need to do a source nat on the traffic..

        The only way such a redirect works if if pihole is on a different vlan then your clients your redirecting.

        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.8, 24.11

        A 2 Replies Last reply Reply Quote 1
        • A
          agaitan026 @johnpoz
          last edited by agaitan026

          @johnpoz you recommend me erase that rule correct? so just leave this lan rules?

          adecf2a1-2ec2-4f2c-bd04-592b4e4cced2-image.png

          or like this

          Allow all port 53 (DNS) traffic from your LAN to pi-hole server

          2a8fcb00-62d9-4d75-a5f1-2b0fa02f0f7c-image.png

          johnpozJ 1 Reply Last reply Reply Quote 0
          • RicoR
            Rico LAYER 8 Rebel Alliance
            last edited by

            May I ask why you run Pihole and not pfBlockerNG ?

            -Rico

            1 Reply Last reply Reply Quote 0
            • johnpozJ
              johnpoz LAYER 8 Global Moderator @agaitan026
              last edited by johnpoz

              If your going to do a port forward.. Then you need a rule to talk to where your port forwarding.

              It should be loopback if your doing the redirection. If you want to forward to pihole directly then you need to make sure you setup outbound nat for such a reflection.

              reflection.png

              Or you end up with this

              dig @1.1.1.1 www.google.com
              ;; reply from unexpected source: 192.168.3.10#53, expected 1.1.1.1#53
              

              When you do something like this.

              portfoward.png

              edit: I am not a fan of redirection.. If you want devices to use pihole, then hand them pihole via dhcp.. And just block all other dns.

              Then just have pihole ask pfsense directly for stuff.. This allows you to resolve your own local stuff, and for pihole to see who asked.

              If you don't want devices to use any thing else - then just block them from doing that. Users hate when their ISP does interception of dns.. But seems ok to do on your own network? Then why are you so mad when the ISP does it ;) It is their network after all that your connected too.

              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.8, 24.11

              1 Reply Last reply Reply Quote 1
              • A
                agaitan026 @johnpoz
                last edited by

                @johnpoz got it, now im clear, its better to have a diff segment for my pihole instead of using the same network on pfsense i should use vlan

                ? 1 Reply Last reply Reply Quote 0
                • ?
                  A Former User @agaitan026
                  last edited by A Former User

                  @agaitan026 Putting you pi-hole on a network dedicated to such things is a good plan. I'm not prepared (no time) at the moment to lay out my setup but I'll say this:

                  Get your network working with unbound as a resolver.
                  Setup your DHCP and Unbound to register leases and static mappings in unbound. Set hosts names along with your static mappings in dhcp.
                  Add the pi-hole on a vlan/network of it's own or with other like devices.
                  Tell your devices (not the ones on the vlan with the pi-hole or the pi-hole) to use the pi-hole for dns with dhcp.
                  Use NAT to redirect (to the pi-hole) those who don't listen to dhcp, if you want.
                  Your devices would then use pi-hole which would then forward to pfsense (unbound).
                  Setup pi-hole to do 'conditional forwarding' (It's in pi-hole dns settings) so that the logs show the hostname dot local domain name.

                  Sounds more complicated than it is. When time permits I'll post up all the settings in pfsense and pi-hole that are relevant.

                  A 1 Reply Last reply Reply Quote 1
                  • A
                    agaitan026 @A Former User
                    last edited by

                    @jwj sounds good, if its possible for you please share your settings :) thank you

                    ? 1 Reply Last reply Reply Quote 0
                    • ?
                      A Former User @agaitan026
                      last edited by A Former User

                      @agaitan026 Will do. Might not be today, however. Sorry if the language above is not precise, it will make more sense when you see the settings.

                      I should add that I like pfblockerng. I use it for some light geo blocking and some other ip lists. I do prefer pi-hole for the GUI and the flexibility to create groups and manage blocklists, blacklisted domains and whitelisted domains on a client by client basis or a group of clients. For example a couple of apps on my Apple TVs will not work unless some domains are whitelisted. I don't want to whitelist them for every client (google ad network stuff), just the apple TV's. With pi-hole you can do that easily directly in the GUI.

                      A 1 Reply Last reply Reply Quote 1
                      • A
                        agaitan026 @A Former User
                        last edited by

                        @jwj correct thats what i like from pihole

                        A 1 Reply Last reply Reply Quote 0
                        • A
                          agaitan026 @agaitan026
                          last edited by

                          This post is deleted!
                          1 Reply Last reply Reply Quote 0
                          • A
                            agaitan026
                            last edited by

                            what i saw with my current setup, if i stop pihole, all my conectivity goes down, any chance to have pfsense as backup dns resolver?

                            ? 1 Reply Last reply Reply Quote 0
                            • ?
                              A Former User @agaitan026
                              last edited by A Former User

                              @agaitan026 Yeah. No DNS resolution but you still can connect to anything by IP.

                              When it happens, say your on a MAC, you just go to network settings and manually put in the gateway until the problem is fixed. I assume windows has likewise settings. You can do that on an iPhone also.

                              Mine (on a Raspberry PI) has never died unexpectedly. I guess you could setup two...

                              I guess the question really is if I have say, 192.168.100.12 and 192.168.10.1 as servers will it use the first always unless the first is unavailable. I'm not sure but I think the answer is no. @johnpoz would know for sure.

                              johnpozJ 1 Reply Last reply Reply Quote 0
                              • johnpozJ
                                johnpoz LAYER 8 Global Moderator @A Former User
                                last edited by johnpoz

                                You can not give a client more than 1 NS and know for sure which one they might query... You just can never know..

                                If your going to give a client more than 1 NS, then you need to make sure that both NS you give it resolve the same stuff.. For example if 1 filters and the other does not - you can not be sure that the client will use the unfiltered one only if the filtered one is offline.

                                Not sure were people get the idea that dns is some fragile thing that requires backup.. If it goes down... Yo will know about it - that is for sure.. Just fix it ;) Or point your client to another NS while you do.

                                The nice thing about dhcp, it is really simple to point your whole network to different NS if you setup goes down for some reason..

                                Using 2 piholes for example works sure - but now your logs are split and you have to look to both to know what say client ABC looked for, etc.

                                I have most of my clients use pihole, unless I don't want them being filtered. If so then I set them to use pfsense. If my pihole went down... Which it never has - running on a old pi 3B.. It would take only minutes to point just directly pfsense for dns.

                                This is my home network - this is not some mission critical network where millions are lost an hour if network is down, etc. Can tell you for damn sure my internet goes out way more often then my dns ;)

                                Do you have a backup internet connection? I would be putting that in place before ever thinking of needing to run more than 1 pihole on my network.

                                If your really concerned. Have a 2nd place you can fire up pihole in a couple of minutes. I would take all of 2 minutes for me to fire up a pihole docker or vm.. And then again don't really need that because if pihole went down - I would just point to pfsense directly, until I could get pihole working again. So I run unfiltered dns while I do that - not concern to be honest. So my wife gets a few ads on her game she is playing on the ipad ;)

                                Clients have a tendency to flip, and check both to see which one is faster, etc. And if for some reason NS1 doesn't answer fast enough, or at all - then switches to 2, and it might not go back to 1 ever or quite some time later. And if you send back a NX, client not going to ask the other one etc. It was told the record didn't exist - so why should it ask another NS? So you could run into a problem where your local records would not resolve, yet all your dns is up.. If your 2 different NS can not resolve the same stuff, etc.

                                You are much better off just using 1 NS, having a fall back you can switch to quickly then trying to running multiple NS at that same time that your clients point to..

                                Another quick way for recovery, is just bring your backup dns online with the same IP... This is really simple via a docker or VM, or another pi for example.. You could have pihole all setup on some other pi, and if your pihole pi goes down. Just bring up other pi with the same IP or secondary IP that is the same as your other device that was running pi.

                                Its not like it takes hours to restore dns if where its running currently goes down - shoot in a pinch, just point everything to googledns while you bring up your local cache, etc.

                                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.8, 24.11

                                A 1 Reply Last reply Reply Quote 1
                                • A
                                  agaitan026 @johnpoz
                                  last edited by

                                  @johnpoz you right i will keep my settings as it right now, is very unlikely that a pihole goes down for 4 5 6 hours,

                                  johnpozJ 1 Reply Last reply Reply Quote 0
                                  • johnpozJ
                                    johnpoz LAYER 8 Global Moderator @agaitan026
                                    last edited by johnpoz

                                    @agaitan026

                                    If it did - pretty sure you would know.. Pretty much instantly ;)

                                    Put a plan in place that if your pi takes a dump, you can restore dns quickly and you will be good.

                                    Depending on your network - it could be something as simple as adding a vip to pfsense so that queries to your pi IP now go direct to unbound on pfsense. Or have a VM you can fire up quickly that has pihole installed on it that you can bring up on the pi that took a dumps IP, etc.

                                    Might be a good idea to test your restore plan as well ;)

                                    You can always just blame any outage on your ISP, to keep the family off your back... Damn ISP down again - those MF's going to call them and give them a piece of my mind ;)

                                    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.8, 24.11

                                    A 1 Reply Last reply Reply Quote 1
                                    • A
                                      agaitan026 @johnpoz
                                      last edited by agaitan026

                                      @johnpoz yeah, im using right now pihole for whm servers for shared hosting and another projects (win active directory etc). What i did right now was to create a VLAN in the pfsense and configured vmware esxi. Now im trying to configure the best way. Something i noted when i use dns resolver, the website loading is kinda slow, but pihole directly its instantly, i may be doing something wrong.

                                      What exactly you guys recommend me? to have clients connect first to pfsense, then pfsense to pihole? or directly to pihole

                                      as you said @johnpoz you are not fan of redirections

                                      ? 1 Reply Last reply Reply Quote 0
                                      • ?
                                        A Former User @agaitan026
                                        last edited by A Former User

                                        @agaitan026 Definitely client -> pi-hole -> unbound

                                        You want unbound resolving not forwarding. There is zero reason to be using cloudflare or google or cloud9. Why would you hand over all that potential data to some third party who may decide to monetize it when you can do that yourself. Unbound resolving is the default on pfsense for good reason.

                                        You would only redirect if you have clients that ignore the config sent from DHCP. The alternative is to just block DNS for those clients that insist on doing their own thing or let them go to google or whatnot.

                                        My Sonos speakers insist on using name servers of their choosing. I redirect them to the pi-hole...

                                        Are you good now? Do you still want to see how I have my DNS related stuff configured? Sounds like you are moving along getting things arranged. I am happy to share some words and screenshots but if your good then I'll save the time...

                                        A 1 Reply Last reply Reply Quote 1
                                        • A
                                          agaitan026 @A Former User
                                          last edited by

                                          @jwj of course will be nice to see your setup. Appreciate it

                                          ? 3 Replies Last reply Reply Quote 0
                                          • ?
                                            A Former User @agaitan026
                                            last edited by

                                            @agaitan026 Okies. Tomorrow morning I think. :)

                                            1 Reply Last reply Reply Quote 1
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.