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

    Easy Question: Block all outside DNS except Pihole

    Scheduled Pinned Locked Moved Firewalling
    7 Posts 3 Posters 407 Views 4 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.
    • J Offline
      jay226
      last edited by

      I believe this rule should do everything I want, but I wanted to have someone else look at it. I'm trying to block all outside DNS requests on the LAN and only allow my Pihole (192.168.1.202 invert match set) to reach out to an upstream server.

      0_1549849317901_InkedFirewallRulePihole_Marked.jpg

      1 Reply Last reply Reply Quote 0
      • DerelictD Offline
        Derelict LAYER 8 Netgate
        last edited by

        PASS TCP/UDP source 192.168.1.202 dest port 53
        REJECT TCP/UDP source any dest port 53

        But anyone can try to spoof IP address 192.168.1.202 in that configuration.

        It would be better to have the pihole on another subnet/interface.

        Chattanooga, Tennessee, USA
        A comprehensive network diagram is worth 10,000 words and 15 conference calls.
        DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
        Do Not Chat For Help! NO_WAN_EGRESS(TM)

        1 Reply Last reply Reply Quote 0
        • J Offline
          jay226
          last edited by

          Thanks Derelict, i understand the your rule suggestion. Does the "inverted match" cover that or is there an issue using it like that?

          "Another subnet/interface" is beyond my understanding. I'm no expert, just an end user. I do appreciate the help.

          1 Reply Last reply Reply Quote 0
          • DerelictD Offline
            Derelict LAYER 8 Netgate
            last edited by Derelict

            Personally I never use ! rules. I despise them. Other people - some of them pretty smart - disagree.

            You are doing block ! 192.168.1.202 which is better than using a pass ! hosts rule to block traffic to hosts.

            But there is no reason for it. If you want to pass it, pass it. If you want to block it, block it.

            It makes the rule set much easier to understand, at least for me.

            Doing this will likely be "good enough" even if a client could spoof 192.168.1.202.

            It'd probably break everything if someone tried that though since there would be two 192.168.1.202 hosts on your network so a lot of things would probably break unless they were pretty good.

            Chattanooga, Tennessee, USA
            A comprehensive network diagram is worth 10,000 words and 15 conference calls.
            DO NOT set a source address/port in a port forward or firewall rule unless you KNOW you need it!
            Do Not Chat For Help! NO_WAN_EGRESS(TM)

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

              While your inverted rule should work, Derelict is not a fan of such rules ;) Which is why he shows explicit way of doing it..

              If your going to use an inverted rule you need to MAKE sure its working.. There things that can mess with doing such rules. pfsblocker adding its vip can mess with it for starters. The better way to do it is to actually block/reject vs doing an inverted allow rule.

              Also you need to block both udp and tcp on 53. DNS can use either.

              edit; Hist point of moving the pihole to another network/interface would prevent users of changing their IP to the piholes IP and being let out for dns. If you moved the pihole to a network that no users are on, then they can not change their IP to to machine the piholes IP and use that rule.

              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 25.07 | Lab VMs 2.8, 25.07

              1 Reply Last reply Reply Quote 0
              • J Offline
                jay226
                last edited by

                Thanks for the input guys. I like to keep things simple. I think I'm going to change the rules to reflect what Derelict was suggesting, separate rules for pass and block.

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

                  His method is cleaner easier to read, and better in the long run. Inverted rules can be useful, and I do use them, they are not for everyone ;)

                  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 25.07 | Lab VMs 2.8, 25.07

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