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

    Selective Routing to VPN - DNS not working

    Scheduled Pinned Locked Moved DHCP and DNS
    23 Posts 4 Posters 4.5k 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.
    • V
      viragomann @vMAC
      last edited by

      @vmac
      The source port must be any.

      NORDVPN is the internal interface, where the devices are connected to?

      Which error do you get?

      Please show the policy routing and the outbound NAT rule.

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

        @viragomann Here is the error that I get when I try to put in this rule without setting NAT Reflection to Disable:
        screencapture-192-168-1-1-firewall-nat-edit-php-2023-02-26-01_36_15.png

        Here is my Outbound NAT:
        screencapture-192-168-1-1-firewall-nat-out-php-2023-02-26-01_37_22.png

        Here is Policy Routing:

        V 1 Reply Last reply Reply Quote 0
        • V
          vMAC @vMAC
          last edited by

          sorry picture was too big.

          Here is Policy:
          image1x1.png
          image1x2.png

          V NightlySharkN 2 Replies Last reply Reply Quote 0
          • V
            viragomann @vMAC
            last edited by

            @vmac
            A policy routing rule has a gateway stated.
            And action "reject" also seems not be proper for a policy routing rule.

            V 1 Reply Last reply Reply Quote 0
            • NightlySharkN
              NightlyShark @vMAC
              last edited by

              @vmac Don't forget the system resolvers (System->General Setup->DNS)

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

                @nightlyshark said in Selective Routing to VPN - DNS not working:

                @vmac Don't forget the system resolvers (System->General Setup->DNS)

                This has nothing to do with the actual case here.
                This setting is for pfSense itself only by default.

                NightlySharkN 1 Reply Last reply Reply Quote 0
                • NightlySharkN
                  NightlyShark @viragomann
                  last edited by NightlyShark

                  @viragomann Because DNS queries come from the same IPv4 as the client queries due to NAT, if the FW itself is configured during install to query, say CloudFlare instead of itself, a DNS leak test will be positive. I mentioned it because it happened to me (NordVPN). Most VPNs specifically require you to forward all DNS to their DNS.

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

                    @nightlyshark
                    We are trying here to redirect all DNS requests from devices which use the VPN to an outside DNS server (over the VPN). If this succeed, which is quite straight forward, the systems DNS settings do not have any impact on the concerned clients.

                    NightlySharkN 1 Reply Last reply Reply Quote 0
                    • NightlySharkN
                      NightlyShark @viragomann
                      last edited by NightlyShark

                      @viragomann I thought so, too. Turns out, gremlins live everywhere. I too have split-horizon DNS, with VPN-only and no-VPN subnets. But, the key problem proved to be Unbound and what servers it forwarded to, or that in recursive mode, it could either query through VPN or WAN for all interfaces. That broke Netflix, Government sites, Banking...

                      Consider this, you block all QUICK (chrome and android), redirect all simple DNS per interface. Still cannot block DoH and DoT without an access list for destination IPs and even if you do, it just breaks everything for the DoH-T clients. Those clients end up querying either nobody at all and just refuse to connect (android), or the servers you specified in DHCP and Radvd which can be:

                      • either external ones (catch them with port forward)
                      • internal ones

                      In the last case, Unbound becomes a problem. You can't split-horizon it. I tried using DNS-Forwarder for the VPN interfaces (forward to VPN DNS) and Unbound for no-VPN clients. Damn thing still leaked. If I changed the system DNS the leaks stopped, but Netflix, Government, Banks broke. I ended up using BIND.

                      My point is, as an answer to the problem that was stated in the first post, the leaks only stop if you force PfSense to query the VPN DNS. I don't know why, it shouldn't, but it does.

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

                        @nightlyshark
                        Again, all these have not even any impact if you redirect DNS requests, as I suggested.

                        You have group of devices, which you policy route to the VPN server.
                        AND you redirect any DNS requests from this group to a public DNS server. Due to the policy routing rule DNS requests are forced to the DNS server as well.
                        You can forward unencrypted DNS requests to where ever you want. If a client tries to request you local unbound on pfSense on say 10.0.0.1 and pfSense redirects it to 8.8.8.8 over the VPN, 8.8.8.8 is responding to the request (while it sees the VPN providers public IP), the respond come back from the VPN and pfSense traslates the source IP of 8.8.8.8 back into 10.0.0.1. So the client doesn't take any notice that the request was answered by another server.
                        And DNS leaks are resolved.

                        So when you redirect DNS requests, they never go to the local unbound.

                        DoH is forced to a public DNS server over the VPN anyway due to policy routeing.

                        DoT, if a public server is requested, can be forced over the VPN as well to prevent DNS leaks. But it cannot be redirected to any other server, even not to the local unbound, since you don't have a matching SSL certificate.

                        NightlySharkN 1 Reply Last reply Reply Quote 0
                        • NightlySharkN
                          NightlyShark @viragomann
                          last edited by

                          @viragomann I didn't doubt you can forward DNS manually, I just said it is problematic. And that in my case with the dns leak, the solution to it was to change the system DNS, as per the instructions of the VPN provider. To remedy the leak and just the leak.

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

                            @nightlyshark said in Selective Routing to VPN - DNS not working:

                            I didn't doubt you can forward DNS manually, I just said it is problematic.

                            Never seen an issue with that and cannot think of any.

                            And that in my case with the dns leak, the solution to it was to change the system DNS, as per the instructions of the VPN provider.

                            This would impact all local devices. But the TO wants only certain "VPN" devices to use the providers DNS to provide leaks and all others use the system settings.

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

                              @viragomann Is this what you are speaking about?
                              LAN rules:
                              screencapture-192-168-1-1-firewall-rules-php-2023-02-26-09_24_06.png
                              IOT rules:
                              screencapture-192-168-1-1-firewall-rules-php-2023-02-26-09_30_53.png

                              Here is the full rule:
                              image1x1.png image1x2.png

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

                                @vmac
                                Yes. Now this tells me that "NORDVPN" is the interface, which you have assigned to the VPN client instance. Hence this is the wrong interface to do the port forwarding.

                                According to your shown rules, there are some devices in the LAN and some in IOT, which you forward to the VPN provider.
                                Now you have to create the suggested NAT port forwarding rules exactly on these two interface.
                                I.e., you need two port forwarding rules for DNS, one on LAN and another one on IOT.

                                V 1 Reply Last reply Reply Quote 1
                                • V
                                  vMAC @viragomann
                                  last edited by

                                  @viragomann this seems to have worked. I will continue to test it for a couple of hours.

                                  I greatly appreciate your help. You went above and beyond to help me here. Thank you.

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

                                    @vmac said in Selective Routing to VPN - DNS not working:

                                    this seems to have worked.

                                    Glad to hear.
                                    You're welcome.

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

                                      @viragomann Just following up, this works perfectly. I have had no DNS leaks since this was implemented and the VPN is working as intended. Thank you very much sir.

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