Interesting, so based on this
1) Set up DNS over TLS using the Merlin WAN UI
2) You can continue to use PBR with OpenVPN (setting DNS to disabled)
3) Add the route directive to the custom config field of the VPN client UI so that the DNS-over-TLS connection is forced through the VPN gateway instead of the WAN
I will try this out, see if it works.
Thanks.
Got curious and decided to test out my own theory. I added the DNS-over-TLS domain name as a route to the OpenVPN client custom config field. And it *would* have worked, were it not for something I'm about to explain.
When using PBR (policy based routing), the router removes the default gateway of the VPN from the main routing table (which is correct; that will eventually be moved to a secondary routing table). But it also removes *all* routes that point to the VPN, which is NOT correct!
Here's a dump of the syslog (note, I have a lot of other route directives besides the one for the DNS-over-TLS domain name, so that's why you see so many removals; the ones that matter for DNS-over-TLS are 162.250.2.3 and 45.77.162.235).
Code:
Feb 7 18:39:15 openvpn-routing: Configuring policy rules for client 1
Feb 7 18:39:15 openvpn-routing: Creating VPN routing table (mode 2)
Feb 7 18:39:16 openvpn-routing: Removing route for 1.0.0.1 to tun11 from main routing table
Feb 7 18:39:16 openvpn-routing: Removing route for 10.81.0.1 to tun11 from main routing table
Feb 7 18:39:16 openvpn-routing: Removing route for 162.250.2.3 to tun11 from main routing table
Feb 7 18:39:16 openvpn-routing: Removing route for 1.1.1.1 to tun11 from main routing table
Feb 7 18:39:16 openvpn-routing: Removing route for 45.77.162.235 to tun11 from main routing table
Feb 7 18:39:16 openvpn-routing: Removing route for 0.0.0.0/1 to tun11 from main routing table
Feb 7 18:39:16 openvpn-routing: Removing route for 128.0.0.0/1 to tun11 from main routing table
Feb 7 18:39:16 openvpn-routing: Adding route for 192.168.1.7 to through VPN client 1
Feb 7 18:39:16 openvpn-routing: Completed routing policy configuration for client 1
Feb 7 18:39:16 ovpn-client1[1133]: Initialization Sequence Completed
Again, it's absolutely correct for the router to remove the following routes from the main routing table because these represent the routes that change the default gateway from the WAN to the VPN.
Code:
Feb 7 18:39:16 openvpn-routing: Removing route for 0.0.0.0/1 to tun11 from main routing table
Feb 7 18:39:16 openvpn-routing: Removing route for 128.0.0.0/1 to tun11 from main routing table
But all the others should be left alone! Those are route directives that we want placed in the main routing table so we can force the router (which is using the main routing table) to use the VPN for those routes.
IOW, as implemented, PBR is just looking for anything that references the VPN in the main routing table (probably just grep'ing for tun11) and removing it, unconditionally.
Ugg.
If it wasn't for this, it would be working. And in my book, this is a flaw in the implementation of PBR. It needs to be *selective* about what it removes from the main routing table wrt the VPN (tun11 in this case) rather than a blanket removal of everything. Most likely the developer never anticipated someone wanting to force the router over the VPN while PBR was active.
Just to be 100% sure I understood the problem correctly, I manually added back the routes to the main routing table, and it worked just fine. NextDNS's website reported the OpenVPN client's public IP in the logs.
I'll probably have to report it as a bug/flaw to
@RMerlin.