HOWTO - Redirect all DNS Requests to Opnsense

Started by Cypher100, July 26, 2018, 03:16:37 AM

Previous topic - Next topic
If I set it like yours, to allow destination 127.0.0.1 for dns and enter google.de into my browser, the browser fails to load the webpage. At the same time, I look into the live view, and I see that my client sends a dns request to 192.168.1.1 and gets blocked.
This is the fact that makes me suspicious and I therefore assume that 127.0.0.1 cannot be the correct destination under Rules>LAN.

Not under Rules > LAN.

NAT > Port Forward

Interface: XY (let's pick LAN)
Protocol: TCP/UDP
Source: any
Destination: any
Destination port: 53
Redirect address: 127.0.0.1
Firewall rule associaton: Pass
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

I think the problem here is that I used the LAN interface as an example, which usually has default rules. Let's assume that I create a new interface. Then there are no rules under Rules>NEW. Everything is blocked per se. I can't even access the Internet. And if I now only create a forward port, with pass, then a client will not be able to connect to Ubound running on the FW. Or am I wrong?

So first I have to create a rule under Rules>NEW that allows a client to contact Ubound. And in this example, this is 192.168.10.1 and not 127.0.0.1, because on the one hand, I can see that the browser runs in a timeout with 127... and on the other hand, I can see it in the live logs, which show the connection from the client to 192.168.10.1 as blocked.

The port forward will allow the DNS request if configured as I wrote. But of course you will need at least an additional firewall rule to permit the browser to actually access the Internet after the DNS request has been answered and possibly - depending on your global NAT setup (automatic/hybrid/manual) also at least one outbound NAT rule.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

How do I allow a single device to bypass the DNS redirect? I have AdGuard installed on my phone (192.168.68.118) and use a different set of lists than I do on my local AdGuard Home setup.

July 28, 2024, 08:12:31 PM #95 Last Edit: July 28, 2024, 08:24:46 PM by Patrick M. Hausen
If you have a port forward rule in place to direct your devices to AGH, then place one rule above that one, source "your phone", flag "do not redirect" set.

Or use the AGH UI  ;)
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

July 28, 2024, 10:17:28 PM #96 Last Edit: July 28, 2024, 10:20:55 PM by toodementianull
Quote from: Patrick M. Hausen on July 28, 2024, 08:12:31 PM
If you have a port forward rule in place to direct your devices to AGH, then place one rule above that one, source "your phone", flag "do not redirect" set.

Or use the AGH UI  ;)

Could you be slightly more specific please? I'm new to OpnSense coming from Asuswrt-Merlin and most of the options and descriptions are still foreign to me.

Show your DNS redirect rule, please.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)


What did you set as source, why are you using source invert, why is the rule disabled?

Please show your current working DNS redirect rule and then I can help you to exempt your phone. OTOH as I alsow wrote the AdGuard home UI allows disabling filtering for individual clients - why not use that?
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

July 28, 2024, 10:51:30 PM #100 Last Edit: July 28, 2024, 10:56:25 PM by toodementianull
Quote from: Patrick M. Hausen on July 28, 2024, 10:37:42 PM
What did you set as source, why are you using source invert, why is the rule disabled?

Please show your current working DNS redirect rule and then I can help you to exempt your phone. OTOH as I alsow wrote the AdGuard home UI allows disabling filtering for individual clients - why not use that?

I used this tutorial which is exactly what's posted in the OP of this thread.
https://homenetworkguy.com/how-to/redirect-all-dns-requests-to-local-dns-resolver/

The rule is disabled until I can figure how how to allow specific devices to bypass it. Why does that matter anyway? I showed you the full config of the rule. Works fine except that I need to be able to allow a device to bypass that rule. Should I have it setup differently?

QuoteAdGuard home UI allows disabling filtering for individual clients - why not use that?

Because that does not solve the issue that I am having. I want to force all devices on LAN to use AGH. That's why I need the rule. But I don't want my phone to be forced to use AGH.

This rule cannot technically force all devices to use AGH - you have LAN net as destination instead of source, you have a source invert and you did not show your source setting, yet.

Please show all details of your rule.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

July 28, 2024, 10:57:50 PM #102 Last Edit: July 28, 2024, 11:06:27 PM by toodementianull
I'm not following. I used the exact setup that's listed in the OP. I accidentally had LAN Net set for Destination. I changed that to LAN Address. I just need to know how to allow a device to bypass this rule.

Interface: LAN
Protocol: TCP/UDP
Destination / Invert: Checked
Destination: LAN address
Destination Port: DNS
Redirect target IP: 127.0.0.1
Redirect target port: DNS
NAT reflection: Disable

July 28, 2024, 11:06:32 PM #103 Last Edit: July 28, 2024, 11:08:47 PM by Patrick M. Hausen
What exactly is the source set to in that rule?

Since I am going to go to sleep now:

1. duplicate the rule
2. set source to "your phone" in the duplicate
3. tick the "No RDR" checkbox in the duplicate
4. make sure the duplicate is above the general redirect rule for all devices in the list

That should do it.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Quote from: Patrick M. Hausen on July 28, 2024, 11:06:32 PM
What exactly is the source set to in that rule?

Since I am going to go to sleep now:

1. duplicate the rule
2. set source to "your phone" in the duplicate
3. tick the "No RDR" checkbox in the duplicate
4. make sure the duplicate is above the general redirect rule for all devices in the list

That should do it.

Source is set to any. I did not realize I had to hit the "Advanced" button to see the input box for source. I will try what you said. Thank you.