OPNsense Forum

English Forums => Virtual private networks => Topic started by: eldee on July 13, 2024, 03:32:01 AM

Title: [SOLVED] Help with Unbound DNS' interaction with 2 ProtonVPN tunnels (DNS leaks)
Post by: eldee on July 13, 2024, 03:32:01 AM
Hey folks,

I am a recent user of OPNSense, who needs help with Unbound DNS and its interaction with my two ProtonVPN tunnels.

I have been trying to setup my new router to achieve the following goals.

For 1. and 2. effectively I followed https://docs.opnsense.org/manual/how-tos/wireguard-selective-routing.html#dealing-with-dns-leaks (https://docs.opnsense.org/manual/how-tos/wireguard-selective-routing.html#dealing-with-dns-leaks) as general setup, and what truly made it work for two wireguard tunnels to ProtonVPN was following both https://www.reddit.com/r/ProtonVPN/s/NrZUVYqARH (https://www.reddit.com/r/ProtonVPN/s/NrZUVYqARH) and what jlficken@ recommended here: https://forum.opnsense.org/index.php?topic=38911.msg195192#msg195192 (https://forum.opnsense.org/index.php?topic=38911.msg195192#msg195192)

For 3. I followed https://homenetworkguy.com/how-to/confused-about-dns-configuration-in-opnsense/ for general understanding of how OPNSense offers knobs to configure DNS, and I then proceeded configuring the system based on that understanding.

I seem to be failing in achieving 4. and here are my brief observations:

This seems to suggest that I misconfigured my system (Unbound? Firewall? NAT?), but I do not know exactly how to find nor resolve the issue.
Any suggestions?

My configuration is below, I tried to redact either private information, or experiments that I currently have disabled, to avoid confusion.

Thank you in advance for the help!

Services-Unbound DNS-General
(https://i.ibb.co/mD5n8Ps/Services-Unbound-DNS-General.png) (https://ibb.co/r72BsXP)

Services-ISC DHCPv4-[LAN]
(https://i.ibb.co/m4M3LKn/Services-ISC-DHCPv4-LAN.png) (https://ibb.co/5LfPN3Q)

System-Gateways-Configuration
(https://i.ibb.co/7zKrmRs/System-Gateways-Configuration.png) (https://ibb.co/59LsHnb)

VPN-Wireguard-ProtonVPN_Denmark_Peer1
(https://i.ibb.co/gVgZRqm/VPN-Wireguard-Proton-VPN-Denmark-Peer1.png) (https://ibb.co/rsy2w8F)

VPN-Wireguard-ProtonVPN-Denmark
(https://i.ibb.co/LRcCqmD/VPN-Wireguard-Proton-VPN-Denmark.png) (https://ibb.co/Gp8V1yf)

Firewall-Settings-Advanced
(https://i.ibb.co/bBd5TRm/Firewall-Settings-Advanced.png) (https://ibb.co/xj5qW8L)

Firewall-Rules-LAN
(https://i.ibb.co/KVfVf6b/Firewall-Rules-LAN.png) (https://ibb.co/RQsQs2Y)

Firewall-Rules-Floating-WAN_ProtonVPN_Denmark-Routing
(https://i.ibb.co/j4378g9/Firewall-Rules-Floating-WAN-Proton-VPN-Denmark-Routing.png) (https://ibb.co/88PFm6n)

Firewall-Rules-Floating
(https://i.ibb.co/qdxP5B1/Firewall-Rules-Floating.png) (https://ibb.co/QfX1d9m)

Firewall-NAT-Outbound
(https://i.ibb.co/0Z9BSXN/Firewall-NAT-Outbound.png) (https://ibb.co/ZKgHPJs)

Firewall-NAT-One-to-One
(https://i.ibb.co/SJS62hn/Firewall-NAT-One-to-One.png) (https://ibb.co/jHt8dcM)

Firewall-NAT-Port Forward
(https://i.ibb.co/9VV0Bk5/Firewall-NAT-Port-Forward.png) (https://ibb.co/HxxyRf8)

Firewall-Aliases
(https://i.ibb.co/Jqsw0GF/Firewall-Aliases.png) (https://ibb.co/NrydQJn)

Interfaces-Virtual IPs
(https://i.ibb.co/FgPszSg/Interfaces-Virtual-IPs.png) (https://ibb.co/xJ4m6pJ)

Interfaces-Overview
(https://i.ibb.co/1nVPn7m/Interfaces-Overview.png) (https://ibb.co/xsvBsX7)

System-Settings-General
(https://i.ibb.co/SJHygTw/System-Settings-General.png) (https://ibb.co/HXR4yvT)
Title: Re: Help with Unbound DNS' interaction with 2 ProtonVPN tunnels (DNS leaks)
Post by: newsense on July 13, 2024, 06:17:06 AM
The whole point of having a firewall is to controll traffic. A revolving door set of policies makes it no more useful than an off the shelf router.


Let's talk Lan rules:

1) Allow Alias to Alias - do whatever you want on whatever port GW 1
2) Allow Alias to Alias - do whatever you want on whatever port GW 2

3) Allow Alias to not_RFC1918 - do whatever you want on whatever port GW 1
4) Allow Alias to not_RFC1918 - do whatever you want on whatever port GW 2

5) Allow LAN IPv4 to ANY - do whatever you want on whatever port - ANY GW
6) Allow LAN IPv6 to ANY - do whatever you want on whatever port - ANY GW



The better ruleset would look like this

1-2)  Port FW rule, TCP/UDP, source (v)LANs, destination ANY destination port 53 - redirect to 127.0.0.1 port 53 (Unbound rule)

Configure Unbound as needed, preferably with DNS over TLS only -- and you don't have to use the Proton DNS IPs (it's in their docs actually if you read it carefully)

3) Allow TCP Alias_IPS_For_GW1 to ANY DPort Alias-Ports(80,443) GW1
4) Allow TCP Alias_IPS_For_GW2 to ANY DPort Alias-Ports(80,443) GW2

Similar rules as 3-4 should exist on other VLANs as needed, depending on what the source or source alias is.


5-6) No such rules should exist on your FW

Any other rules can be added before or after 3-4 rules, depending on which IPs it applies to and what the destination/port is.
Title: Re: Help with Unbound DNS' interaction with 2 ProtonVPN tunnels (DNS leaks)
Post by: eldee on July 13, 2024, 06:50:49 PM
I appreciate the reply, but I am not sure I completely understand. This is certainly due to my ignorance, so please bear with me.

Quote3) Allow TCP Alias_IPS_For_GW1 to ANY DPort Alias-Ports(80,443) GW1
4) Allow TCP Alias_IPS_For_GW2 to ANY DPort Alias-Ports(80,443) GW2
I don't understand this rule. For my setup is the configuration below what you meant?

Which interface should I use from my example? WAN_ProtonVPNDenmark and a separate similar rule for WAN_ProtonVPNItaky? Or LAN?
Note: I am using subnets on the LAN, I do not use VLANs

Why only ports 80 and 443?

Quote1-2)  Port FW rule, TCP/UDP, source (v)LANs, destination ANY destination port 53 - redirect to 127.0.0.1 port 53 (Unbound rule)

This seems a NAT Port forward rule that does two things
Why do I need to do 2. explicitly? (Sorry again if this is trivial, I am trying to learn.)

More general follow ups to your reply:

Again thank you in advance for all the help, and for going through my config.
I am trying to learn by reading and doing, so I apologize if my questions are too trivial, and if that is the case, feel free to redirect me to existing tutorials that I may have missed, covering a similar setup.

Cheers!
[/list][/list]
Title: Re: Help with Unbound DNS' interaction with 2 ProtonVPN tunnels (DNS leaks)
Post by: DEC670airp414user on July 14, 2024, 01:59:38 PM
your second screen shot under DNS is empty..
at 10.2.0.1 and reboot those devices and do a dns leakiest

or whatever DNS server proton uses now for their wireguard tunnels
Title: Re: Help with Unbound DNS' interaction with 2 ProtonVPN tunnels (DNS leaks)
Post by: eldee on July 16, 2024, 03:56:52 AM
Quoteyour second screen shot under DNS is empty..

That is empty by design. I only want to use ProtonDNS for clients on the 13 and 14 subnets. For all other subnets I want to be able to use Unbound as resolver. Do you see a reason why this setup cannot work?
Title: Re: Help with Unbound DNS' interaction with 2 ProtonVPN tunnels (DNS leaks)
Post by: eldee on July 17, 2024, 09:54:52 PM
For future reference, I found out the issue with my configuration.  ;D

I had to disable ipv6 on the WAN interface (I set Interfaces>[WAN]->IPv6 Configuration Type to "None"). It seems that my system's ipv6 configuration (or lack of) was causing the DNS leak. As soon as I disabled it, everything started working as expected.

I wish I had a better understanding of why exactly this caused the leak.. In other words how does OPNSense prioritize firewall rules between ipv4 and ipv6 stacks, when your ISP assigns to your router one address per stack? :o