dnsmasq strict interface handling
I want to force proxy users to use dnsmasq instead of unbound. Reason: Do some DNS Rewrites only for proxy users. Tried to bind dnsmasq to 5353, but I can't specify the DNS Port in the bind config. I created a virtual IP for that, where unbound does not listen to. But opnsense GUI doesn't allow me to explicit select this virtual IP (unbound opnsense gui dialog does). Please implement it the same way, so both unbound and dnsmasq can run on port 53 on seperate IPs/Interfaces.
No, we will not work on binding arbitrary plugins to single VIPs. We need to find another way.
Ok, I understand. Until there is another possibility, I just deactivated dnsmasq in GUI and run it manually directly from the shell.
I might be missing something, but Dnsmasq can be switched to 5353, but then Unbound has to be on 53 to provide response to normal queries from the system. Then "proxy users" come into the picture but what does that include? Are you running a web proxy on OPNsense? Normal (or PAC/WPAD) or transparent?
My approach is, that I want to have web-filtering for some users in my LAN. I use the opnsense built-in squid with some lists for that, forced in transparent proxy mode for these IPs, which works great. Additionally, I want that these users (who are forced to use squid) can access google and youtube only in "restricted" mode. To achieve this, the google.com etc. DNS entries have to be rewritten (CNAME to forcesafesearch.google.com) in DNS (not possible in Squid). Other users in the LAN should not have this enabled. So I can't do this in opnsense's unbound (which is my primary dns), as it would affect all users then. As it is possible to use a specific nameserver in squid, I had the idea to run dnsmasq in parallel and do the rewriting there and use dnsmasq only for squid. But unfortunately it is not possible to say squid, that the DNS server is running on another port than 53.
You can rewrite DNS queries like you use the proxy in port forwards: https://forum.opnsense.org/index.php?topic=9245.0
Would that already solve your issue?
I already use this to prevent my users using 8.8.8.8 or something like that. But the clients that are forced to use the proxy don't use normal DNS lookups for HTTP(s), instead Squid does do the DNS lookups.
Ok, the initial query will be through your Unbound for sure, the rest of the pages is through Squid as you said.
How about Dnsmasq on 53, redirect 8.8.8.8-ish to 5353 where Unbound listens. That would solve the Squid issue?
Good idea! Unbound now listens on 5353, everything from the lan going out to 53 is redirected to this unbound. And dnsmasq is configured to listen on 53 and use 127.0.0.1#5353 as upstream server. Thanks a lot!
@gr1nd yay, cool :) not sure if you are already doing it / it's useful for you: if you use an alias to redirect certain clients to proxy you can use the same alias to directly move their dns to Dnsmasq as well so they use the same server that Squid is using.
Cheers, Franco
Makes sense, I will add this as well :) Cheers, Michael