Please help with DoH setup (CleanBrowsing DNS-Over-HTTPS)

Hi,

Would anyone be so kind as to help me with basic DoH setup using CleanBrowsing DNS?
I’d like to use the following DNS servers (IPv4 only) listed on https://cleanbrowsing.org/filters/ site:

Here is what I tried so far:

First, I’ve make sure that no Dynamic Servers are in use. I’ve unchecked “Use Peer DNS” option from the PPPoE interface.

Next, I have added static DNS entries:

/ip dns static
add address=185.228.168.10 name=adult-filter-dns.cleanbrowsing.org
add address=185.228.169.11 name=adult-filter-dns.cleanbrowsing.org

After that, I have added the following NAT rules:

/ip firewall nat add chain=dstnat action=redirect protocol=tcp dst-port=53
/ip firewall nat add chain=dstnat action=redirect protocol=udp dst-port=53

Finally, I have added the doh.cleanbrowsing.org/doh/adult-filter/
line into the Use DoH Server field:

Now, the problem is I do not know what to do next.

  • Not sure if it’s OK to completely skip DoH Certificate. PEM (cert) has validity until Wed, 15 Feb 2023 - I’m afraid that the DNS will stop working when the certificate will expire, but I don’t know if it works like that?
  • No idea how to configure the DHCP Server now for LAN clients. Normally I have the above 2 DNS servers set as “DNS Servers” for the DHCP Network. Should I select “No DNS” option instead?

After selecting “No DNS” for DHCP Network, I’m getting the following errors and DNS is not working at all for LAN clients:

Your router doesn’t know the IP address of this server, you must add a IP → DNS → Static entry for it.

it looks like it could be these two IP adderesses:

doh.cleanbrowsing.org. 3600 IN A 185.228.168.168
doh.cleanbrowsing.org. 3600 IN A 185.228.168.10

Then it should work.

P.S: this step is also mentioned in our DoH video https://www.youtube.com/watch?v=w4erB0VzyIE

Hi Normis!

Thank you for the reply. Please note that I have already added static DNS entries, as I clearly stated in the post above :slight_smile:
Are the entries that I have posted incorrect?

But the error is clearly that the DNS name can’t be resolved. it means you added DNS static entries for the wrong DNS address

your static entry is for **adult-filter-dns.**cleanbrowsing.org
but your DoH config is for doh.cleanbrowsing.org

Ahh I understand now! :slight_smile:
I have added static DNS entry for doh.cleanbrowsing.org and the error is gone now. Thank you!

Should I leave the DNS entries in DHCP Server for DHCP Network? If I select “No DNS” option, the DNS is not working for LAN clients:

This config is also wrong. Did you watch the video?
If you are using the router as the DoH client, you should not send the clients to the unencrypted DNS server, it makes no sense.

Remove the DNS servers entries from the DHCP Network settings, replace it with the router IP 192.168.0.1 (probably). The LAN devices should use the router as their DNS server, and the router will then query the DoH server.

Yes, I did watch the video! It was from this video that I learned about DoH :slight_smile:
But I think the video does not mention how to setup DHCP Network…

I think it is working now:

and here from the client:

It should be OK now?

Well if from the client device you are now able to use the internet, it should be working.
Now go visit pornhub and see if blocking is also working :smiley:

I think filtering works great, but I’m not sure how to verify if everything indeed goes through the DNS-Over-HTTPS.
If I setup a custom DNS on the client side, for example 8.8.8.8 I still can access shady content like for example torrent sites. Is it normal?

No you can’t, this is where the NAT rule comes into play.
/ip firewall nat add chain=dstnat action=redirect protocol=tcp dst-post=53

this one will catch any other DNS request and send it to your router.

Also, to be extra safe, you can block UDP port 53 from leaving your router, so no regular DNS request can be sent from router to web:

/ip firewall filter add chain=output action=drop protocol=udp dst-post=53

@Świętopełek

Let’s make one thing clear right away: Beyond ideologies, objectively whatever you do you will never prevent a person from doing what he wants with himself.

A DNS filter will never prevent you from downloading a movie from any type of torrent,
nor will it prevent browsers from using their DoH that completely bypass yours, etc, etc, etc…

The DoH is designed to liberate the connection from the ideology of the provider.
(and help the Big Co. for get better the browsing data of the end users, and prevent the use of ad-blocking, etc.)

If you don’t have full control of the device used, and you are not with the person using it at that moment, you cannot prevent anything at all, and you remain helpless.

Rextended, if you see what kind of server he uses, most likly 99% it is for home environment to stop children from getting viruses or seeing porn banners.
So hold your ideology speech

@normis
¯_(ツ)_/¯
Ok…

@Świętopełek

Unfortunately, as more and more browsers have it integrated, you can’t prevent the browser from using DoH as well, which completely bypasses your settings.
Also some smartphone and tablet use embedded DNS (like 8.8.8.8 etc.) and ignore completely the DHCP server.
For prevent redirect or blocking, next gen of smartphone and tablet use own DoH…


A DNS filter will never prevent you from downloading a movie, image, etc. from any type of torrent (often torrents do not use DNS at all),
and do not prevent any other method, like spam email, and others.

Yes the reasons are completely irrelevant. Please do not derail my topic! :smiley:
And yes, this is just home environment.

@rextended: Thank you for the comment, I understand that it is not possible to prevent users from using workaround options, but it is not my intention.
My intention is to have a simple DoH setup on my home router, and I’m still struggling with that. My real concern is NOT “why it is not blocking” but rather “why this option is not working”.

I have those 2 options from the very beginning:

/ip firewall nat add chain=dstnat action=redirect protocol=tcp dst-port=53
/ip firewall nat add chain=dstnat action=redirect protocol=udp dst-port=53

As noted above, I think it is not working - with custom 8.8.8.8 setup on the client shady content is available.
Should I now add the line below on top of that?

 /ip firewall filter add chain=output action=drop protocol=udp dst-port=53

as also @Normis wrote,
you need to be sure that all DNS request must go to the RouterBOARD.

If for some reason some device bypass the router, setting manually the DNS 8.8.8.8 on IPv4 config, this mean than something is not how it appear.

You must provide a detailed network diagram, with real interlnals IP, anonymized external IP, and the, censored from private data, configuration export of the device.

dst-nat happen before forward on filter,
for drop other DNS request not directly directed to 192.168.0.1, and not intercepted, you must use forward chain. (this still do not block internal browser DoH)

/ip firewall filter
add chain=forward action=drop dst-address=!192.168.0.1 protocol=tcp dst-port=53
add chain=forward action=drop dst-address=!192.168.0.1 protocol=udp dst-port=53

Hmm this is so difficult to understand :frowning:

I have a very simple setup, most of the settings are just defaults:

https://i.imgur.com/l3W5H3L.png
https://i.imgur.com/Ow34ngL.png
https://i.imgur.com/FifbI0K.png
https://i.imgur.com/NCwy7pj.png
https://i.imgur.com/JSHfs4m.png
https://i.imgur.com/X4iKSCA.png

So what should I use from the 5 lines below? All of them, or only first 2?

/ip firewall filter add chain=forward action=drop dst-address=!192.168.0.1 protocol=tcp dst-port=53
/ip firewall filter add chain=forward action=drop dst-address=!192.168.0.1 protocol=udp dst-port=53

/ip firewall filter add chain=output action=drop protocol=udp dst-port=53

/ip firewall nat add chain=dstnat action=redirect protocol=tcp dst-port=53
/ip firewall nat add chain=dstnat action=redirect protocol=udp dst-port=53

but you wrote them by hand, isn’t it an export???

dst-POST command does not exist

You can omit the “output”, but when you do test, you must first reboot devices for clean internal caches…

Sorry just a typo, I’ve updated my post.
Not an export, but very same setting (on router executed without typo of course)

the difference between writing something by hand versus doing an export,
it’s the same between the idea of how something is configured and how it is actually configured.