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

    When trapping rogue DNS requests, logging looks strange

    Scheduled Pinned Locked Moved DHCP and DNS
    15 Posts 4 Posters 1.2k 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.
    • johnpozJ
      johnpoz LAYER 8 Global Moderator @gniting
      last edited by

      @ibbetsion what are you seeing in the log that you don't think you should be seeing exactly?

      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

      gnitingG 1 Reply Last reply Reply Quote 0
      • V
        viragomann @Gertjan
        last edited by

        @Gertjan said in When trapping rogue DNS requests, logging looks strange:

        I'm wondering, why you're caring about.

        He probably want to find the devices that misbehave ?

        Yes, I got it. But what's the benefit of that.
        The redirection works and all is good anyway, even if some clients keep on trying to access another name server. 😊

        1 Reply Last reply Reply Quote 0
        • gnitingG
          gniting @johnpoz
          last edited by gniting

          @johnpoz said in When trapping rogue DNS requests, logging looks strange:

          @ibbetsion what are you seeing in the log that you don't think you should be seeing exactly?

          @johnpoz my expectation is that I will only see entries in the log that are being blocked. However, I am seeing all DNS queries.

          I made the change suggested by @Gertjan and changed the NAT rule to use 127.0.0.1 vs 192.168.7.1 and doing that did result in the logs only capturing the denied DNS queries, but now I see the dreaded unexpected source error when using nslookup and forcing the use of an external DNS server.

          ❯ nslookup cloudflare.com @8.8.8.8
          ;; reply from unexpected source: 192.168.7.1#53, expected 72.52.178.23#53
          ;; reply from unexpected source: 192.168.7.1#53, expected 72.52.178.23#53
          ;; reply from unexpected source: 192.168.7.1#53, expected 72.52.178.23#53
          ;; connection timed out; no servers could be reached
          

          Unsure what's going on.

          johnpozJ GertjanG gnitingG 3 Replies Last reply Reply Quote 0
          • johnpozJ
            johnpoz LAYER 8 Global Moderator @gniting
            last edited by johnpoz

            @ibbetsion ah yeah - that is client error/warning - change redirect to loopback and you wan't see those.

            Your saying your seeing that with looback as your redirect?

            If you were directing to loopback, why would it be saying 192.168.7.1 - are you doing an outbound nat into your network?

            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

            1 Reply Last reply Reply Quote 0
            • GertjanG
              Gertjan @gniting
              last edited by Gertjan

              @ibbetsion said in When trapping rogue DNS requests, logging looks strange:

              but now I see the dreaded unexpected source error when using nslookup and forcing the use of an external DNS server.

              nslookup is there to check things : you gave it the 'wrong' DNS, so it complains. That's perfect.
              When you run nslookup on your PC, there won't be any errors, because :
              Your LAN has 192.168.1.1/24 - your PC uses a 192.168.1.x/24, and got a DNS that is 192.168.1.1 - and a gateway that is 192.168.1.1.
              So, when you start nslookup, it will use the default DNS, obtained by DHCP, which is 192.168.1.1, and you will see no complaints.
              Devices that behave not the correctly, as they use for example 8.8.8.8 even when they got from DHCP '192.168.1.1", well, let them complain, they asked for it.

              I tested all my network devices : NAS, printers, DVR's PCs and other stuff : they all respect my DNS : all devices use 192.168.1.1 (that is : they don't : they use the IPv6 equivalent, as IPv4 is less used these days)

              My iPad, iPhones : same thing : if they got an DNS from my DHCP server (pfSense), they will respect that DNS, and (oh, lol : how can this be true :) they will not use 8.8.8.8 or some other DNS harvester. I guess : phone apps can't do their own DNS, this is not allowed.
              Note to myself : I'll have to try that ones : if (local) DNS doesn't work, will they start to resolve ? Or just bail out ?

              I use the "Redirecting Client DNS Requests" rule set on my captive portal, as there are many 'other brand' wifi devices behaves differently, even when they got 'DNS is 192.168.1.1' they still insist in using 8.8.8.8 for everything (because they have to call home, I guess) and this will break the captive portal : they can't login.
              They can't even contact 8.8.8.8 (or 1.1.1.1 or who ever) because the portal will not allow this.

              Devices that use a network should respect that network's gateway (if not : no internet) and that network's DNS - if not, also ok, let them find the conclusion : go connect some where else.
              They will auto comply ^^

              No "help me" PM's please. Use the forum, the community will thank you.
              Edit : and where are the logs ??

              1 Reply Last reply Reply Quote 0
              • gnitingG
                gniting @gniting
                last edited by

                @ibbetsion said in When trapping rogue DNS requests, logging looks strange:

                @johnpoz said in When trapping rogue DNS requests, logging looks strange:

                @ibbetsion what are you seeing in the log that you don't think you should be seeing exactly?

                @johnpoz my expectation is that I will only see entries in the log that are being blocked. However, I am seeing all DNS queries.

                I made the change suggested by @Gertjan and changed the NAT rule to use 127.0.0.1 vs 192.168.7.1 and doing that did result in the logs only capturing the denied DNS queries, but now I see the dreaded unexpected source error when using nslookup and forcing the use of an external DNS server.

                ❯ nslookup cloudflare.com @8.8.8.8
                ;; reply from unexpected source: 192.168.7.1#53, expected 72.52.178.23#53
                ;; reply from unexpected source: 192.168.7.1#53, expected 72.52.178.23#53
                ;; reply from unexpected source: 192.168.7.1#53, expected 72.52.178.23#53
                ;; connection timed out; no servers could be reached
                

                Unsure what's going on.

                @johnpoz here's a screenshot with the rule configuration and a new outbound NAT rule that I created to deal with the "unexpected source" error. Unfortunately, the error still persists.

                @Gertjan while I understand your sentiment, I don't want to take away DNS resolution from the "rogue" device because it may render is useless. That means family will scream at me for X device not working :)
                screenshot-TeNpc2wP.png

                johnpozJ GertjanG 2 Replies Last reply Reply Quote 0
                • johnpozJ
                  johnpoz LAYER 8 Global Moderator @gniting
                  last edited by

                  @ibbetsion said in When trapping rogue DNS requests, logging looks strange:

                  hat I created to deal with the "unexpected source" error.

                  Huh - no there should be no outbound nat rule - that could be causing you and issue.. If you forward to loopback your client would not know it not talking to 8.8.8.8

                  So this normally happens when you forward to some other NS on the same network as the client..

                  So for example..

                  I just duplicated it again

                  ;; reply from unexpected source: 192.168.3.10#53, expected 8.8.8.8#53
                  ;; reply from unexpected source: 192.168.3.10#53, expected 8.8.8.8#53
                  ;; reply from unexpected source: 192.168.3.10#53, expected 8.8.8.8#53
                  

                  if I setup a redirect on my 192.168.3.0/24 network and send traffic to pihole I run on this network at 192.168.3.10, and do a query from my client at 192.168.3.32 to 8.8.8.8

                  This has been gone over a few times - here is an old thread.

                  https://forum.netgate.com/post/920206

                  What is this 192.168.7.1 your trying to redirect too.. The problem is when your client tries to talk to say 8.8.8.8 and sends traffic to your router to get sent there, and your router sends it to something else on the same network, and it directly answers the client - the client will say hey wait a minute I was trying to talk to 8.8.8.8 via my gateway, why is this IP sending me an answer.. That is not where I sent it.

                  So you can either redirect to something on a different network, or loopback, etc. Or sure even an IP on pfsense should work. But if your going to redirect to something on the clients network - and it answers directly then yeah more than likely your going to have issues with the client not liking that he gets answer from something else than where he thought he was sending it.

                  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

                  gnitingG 1 Reply Last reply Reply Quote 0
                  • gnitingG
                    gniting @johnpoz
                    last edited by

                    @johnpoz said in When trapping rogue DNS requests, logging looks strange:

                    What is this 192.168.7.1 your trying to redirect too.

                    192.168.7.1 is the pfsense router. I want all DNS queries to go through the DNS server running on this system.

                    I deleted the outbound NAT rule. It was useless.
                    With the setup now, I do get what I want, which is that all rogue DNS queries are routed to my desired DNS server. But, the missing part is that I still can't log these. Since NAT rules are executed before other rules, the redirect happens before any logging can take place and NAT rules themselves don't allow for any logging.

                    Am I just overthinking this? 🙄

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

                      @ibbetsion Yes nat is before rule - but the rule would still log since the firewall has to allow the forward.

                      redirect.jpg

                      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

                      1 Reply Last reply Reply Quote 0
                      • GertjanG
                        Gertjan @gniting
                        last edited by

                        Just this one :

                        @ibbetsion said in When trapping rogue DNS requests, logging looks strange:

                        That means family will scream at me for X device not working

                        That's the ever ongoing discussion between "you and the others".
                        You : want to protect the entire network, and also from the others hurting themselves and/or your LAN. You don't want them to shoot in their own foots. Everybody knows all about security and that they should be careful .... and then they tap on the "Install tiktok" button.
                        Life is hard, .... but we keep on smiling.

                        No "help me" PM's please. Use the forum, the community will thank you.
                        Edit : and where are the logs ??

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