By default, it works as a caching recursive resolver, which means it will query the root servers, etc… and use port 53 (UDP & TCP). It can also work as forwarder and forwards requests to upstream DNS servers. In that case, DoT (DNS over TLS) can also be used and unbound will use port 853 TCP to communicate with the upstream servers (or other custom ports that those servers might support).
I’m preventing my kids from going around the block by trying to use another DNS server. As of now they don’t even know how I’m blocking them. If they were to figure it out and try the options you’ve listed, I’ll shut off their internet on the firewall.
I get that. That is news to me a little bit, but I don’t understand how it is relevant. That browser is doing UDP connections to youtube. How did the browser resolve youtube.com to an IP address to initiate that UDP stream? If the DNS blocking works and the browser cannot resolve the name youtube.com to a valid IP address, I don’t see how the browser makes an HTTP/3 connection via UDP. Assuming the person uses some technology (DoH, VPN, etc.) to bypass the DNS blocking tricks, which means they can resolve the name youtube.com to a valid IP, they’ll be able to use HTTP/3 or just good old HTTP/2.
There isn’t a situation where HTTP/2 is blocked but HTTP/3 works, is there? Either DNS blocking works and neither HTTP/2 nor HTTP/3 work, or DNS blocking is bypassed and both HTTP/2 and HTTP/3 work fine. What am I missing?
It’s now very easy to have secure DNS turned on. Mobile OSes have settings to turn them on at the OS level, same with Windows. Every modern web browser now either use secure DNS by default or have setting to turn that on. So, you just have to assume that DNS blocking is useless against someone who know how to use the search engine for two minutes.
As for why UDP and HTTP/3 are relevant. As other have posted in the thread. With HTTP/2 and without ECH (encrypted client hello) support from the sites, it was until recently possible, with helps from the requirement for SNI, to “block” traffic to sites using HTTPS and HTTP/2 by using the tls-host filter. Because in the first packets of the HTTPS connection the domain name is sent in clear text. But that feature from RouterOS only supports TCP and older HTTP protocols. HTTP/3 uses QUIC (over UDP) and also with ECH the domain name is no longer sent in clear text.
So, with secure DNS and HTTP/3, there is no way for you on the router running RouterOS to know whether someone in your LAN is opening YouTube anymore. Unless you somehow have the list of all possible IP addresses used by Google to serve the site and its videos.
If a site supports both HTTP/2 and HTTP/3, even if you successfully identify and block the HTTP/2 connection to it, eventually the users will still be able to access the sites. Because nowadays, to profit from the latency advantages that HTTP/3 brings immediately, even when visiting a brand-new site, browsers will try to establish both connections, TCP for HTTP/2 and QUIC for HTTP/3 at the same time. And if HTTP/3 “wins” (because of lower latency) the browsers will switch to using it immediately and don’t even wait for the HTTP/2 connection to complete. Here you can see my browser (Edge) says that it switches to using HTTP/3 because it won the race when I tried to access medium.com
Also, last November RFC 9460 has became “Proposed Standard”. With this (HTTPS Resource Record in DNS) sites are now able to instruct browsers to always use HTTP/3, there is no need to initiate the parallel HTTP/2 connection. Modern browsers currently already query for RR type 65 (HTTPS RR) when looking up the domain with DNS, and CDN like Cloudflare already enable the records when the hosted site support HTTP/3. Here you can see apln=“h3,h2” in the HTTPS record as an example.
The best way for blocking sites - at least from the results I have been able to accomplish - is as follows.
Find all domain names related to a service. This requires some manual input from the user, but there are blocklists on Github. Netify.ai is also very useful.
Add all those domain names to an address list. This is easiest when done through the terminal. For example…
Next add two firewall rules. One looks at the IP addresses and adds it to a list with a TTL of 30 days. Remember to move it to the correct position/number after adding it.
Make sure your MikroTik’s DNS server accepts external queries (while also blocking queries from WAN!) and use it in your DHCP Server. This is important because if the client device requests the IP of ‘youtube.com’, and it goes through the MikroTik, the firewall will memorise the IPs and it will work very effectively! My DNS config is as follows…
The reason that this does not work well is that there are multiple addresses for each domain name, and that the returned addresses vary depending on where the DNS request is coming from.
When your router is making DNS requests for these domains via the DNS resolvers configured in the router, it can get different addresses than the user gets via the 8.8.8.8 or 9.9.9.9 or whatever resolver they use in their phone!
Ok. that’s the issue. You’re assuming DNS blocking is trivially bypassed. Because none of the things you mention are relevant if DNS blocking works. SNI, ECH, QUIC, etc. all require DNS first to look up the IP to talk to.
I don’t see any network-level way of blocking a web site, given just its domain name, like youtube.com. That was how I opened the discussion. There’s no practical way to block the IP addresses, to block ports, no SNI inspection, etc. That’s why I started with talking about how to block DNS resolution for a domain, highlighting all the ways that it has limitations. Everyone seems to have piled in to point out all the ways that DNS blocking can be bypassed, which are all true, but that doesn’t yield any practical result for the OP. I’m going to focus on making it hard to bypass DNS blocking.
That will be an endless uphill battle.
When you are selling such a limited service (or your clients buy it and ask you to maintain the router) you should simply explain to them that it has limited usefulness in today’s world, and that it will easily be saturated.
And tell them that their policy should be “no video streaming or other high-bandwidth applications”.
“blocking youtube” is not going to bring you anything. there are plenty other video services and you cannot block all of them.
instead, maybe focus on some queueing setup so that high-bandwitdh users do not adversely affect low-latency users (like VoIP).
If you have limited bandwidth, I would use some QoS.
Example if you have 10MBps total and 4 users, you could give 2.5MBps to all 4.
If some of the 4 does not use all their bandwidth, you can share it with the rest or the one who needs more.
Edit, if this is for children, then its education.
Not with MT equipment, as stated you need to procure high end routers with IDS/IDP, and then pay for subscription services to use their de-encryption engines to look at https traffic etc… Now reading above maybe that is not enough. I know on the enterprise stuff I use, its not accessible, so with enough $$$ perhaps its still possible.
Anything less then the above anyone is selling is horse sheite.