Dns DoH and port 53

Hello Mikrotik fellows.

i'm trying to figur out if my dns DoH connection is working properly.

When i torch my pppoe wan connection i can spot port 53 coming up on the SRC and some random port like 55553 on the DST.

Does this indicate there is something wrong with the config?

DNS is using port 53
DNS over TLS is using port 853
DNS over HTTPS is using port 443

Please share /ip dns to check if the settings are correct. Once you specify a DoH server, it will be used. Only when the URL has to be resolved, a standard DNS query will be performed once.

Hello erlinden,

thank you for your reply.

/ip dns
set allow-remote-requests=yes servers=94.140.14.49,94.140.14.59 use-doh-server=https://d.adguard-dns.com/dns-query/********* verify-doh-cert=yes
/ip dns static
add address=192.168.88.1 comment=defconf disabled=yes name=router.lan type=A
add address=94.140.14.49 name=d.adguard-dns.com type=A
add address=94.140.14.59 name=d.adguard-dns.com type=A

So, if i understand you right, the use of the port 53 that i spotted on the torch is related to the resolver?

Is that also why, IP Service List shows up 2 entries with name resolver both on port 53, for tcp/udp ?

I wouldn't expect a DNS request as you have static entries for this hostname.

Could it be that a client has a static DNS entry?
Do you have default firewall (to exclude DNS requests from WAN)?

You can temporarily point the DoH setting to Cloudflare https://cloudflare-dns.com/dns-query, then go to https://one.one.one.one/help/.

If it shows:

image

then your router is correctly configured to user DoH, and you just have to switch back to the URL from Adguard.

I'm not aware of a client with a static dns entry, but i had the conception that if this would be the case, the router would replace this with the DoH.
I also thought the resolving is also done on port 443.



/ip firewall filter
add action=accept chain=input comment="defconf: accept established,related,untracked" connection-state=\
    established,related,untracked
add action=drop chain=input comment="defconf: drop invalid" connection-state=invalid
add action=accept chain=input comment="defconf: accept ICMP" protocol=icmp
add action=accept chain=input comment="defconf: accept to local loopback (for CAPsMAN)" dst-address=\
    127.0.0.1
add action=drop chain=input comment="defconf: drop all not coming from LAN" in-interface-list=!LAN
add action=accept chain=forward comment="defconf: accept in ipsec policy" ipsec-policy=in,ipsec
add action=accept chain=forward comment="defconf: accept out ipsec policy" ipsec-policy=out,ipsec
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" connection-state=\
    established,related disabled=yes hw-offload=yes
add action=accept chain=forward comment="defconf: accept established,related, untracked" connection-state=\
    established,related,untracked
add action=drop chain=forward comment="defconf: drop invalid" connection-state=invalid
add action=drop chain=forward comment="defconf: drop all from WAN not DSTNATed" connection-nat-state=!dstnat \
    connection-state=new in-interface-list=WAN
add action=drop chain=forward in-interface=Wifi1 out-interface=bridge
add action=drop chain=forward in-interface=Wifi2  out-interface=bridge
add action=drop chain=forward in-interface=Wifi3  out-interface=bridge
add action=drop chain=forward in-interface=Wifi4  out-interface=bridge
add action=drop chain=forward in-interface=Wifi5  out-interface=bridge
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" ipsec-policy=out,none out-interface-list=\
    WAN
/ip firewall service-port
set ftp disabled=yes
set tftp disabled=yes
set h323 disabled=yes
set sip disabled=yes
set pptp disabled=yes
/ip service
set ftp disabled=yes
set ssh disabled=yes
set telnet disabled=yes
set www disabled=yes
set winbox address=192.168.77.2/32
set api disabled=yes
set api-ssl disabled=yes

Hi CGGXANNX,

thank you for your hint. I stumbled over the cloudflare check too, but didn´t thought about switching to Cloudflare settings to verify.

Interception of DNS requests can be handled by the firewall, it would require a (actually 2) dst-nat rules. Both for UDP and TCP. But be aware that when the client uses DoT or DoH, nothing is intercepted.

add action=dst-nat chain=dstnat comment="Make Mikrotik preferred dns server UDP" dst-port=53 protocol=udp to-addresses=[IP of the router] to-ports=53
add action=dst-nat chain=dstnat comment="Make Mikrotik preferred dns server TCP" dst-port=53 protocol=tcp to-addresses=[IP of the router] to-ports=53

Can you share the output of:

/ip dhcp-server network export

Here is the DNS server set for the DHCP server to supply to the clients.

/ip dhcp-server network
add address=192.168.22.0/24 gateway=192.168.22.1
add address=192.168.33.0/24 gateway=192.168.33.1
add address=192.168.44.0/24 gateway=192.168.44.1
add address=192.168.66.0/24 gateway=192.168.66.1
add address=192.168.88.0/24 comment=defconf dns-server=192.168.88.1 gateway=192.168.88.1
add address=192.168.99.0/24 gateway=192.168.99.1

If you want to understand what DNS requests are performed on your router, you can try using the packet sniffer to find that out.

Okay...is it correct that only clients on the 192.168.88.0/24 network should do DNS requests? Perhaps you can give some more insights...as you seem to have 6 segments.

With that setup, on 88 is provisioned 192.168.88.1 and in all the others dynamically the DNS of the RouterOS, if any (94.140.14.49 and 94.140.14.59),
but the device is still free to use DoH, DoT, QUIC, & Co.

Actually no. The setup of the 6 Wifi networks was done to seperate the devices from each other. I used client isolation but thought a seperate subnet wouldn´t hurt.

Blockquote
With that setup, on 88 is provisioned 192.168.88.1 and in all the others dynamically the DNS of the RouterOS, if any.

Whats the implication of this, is it a general problem that the encrypted traffic does not get intercepted?

Blockquote

udp to-addresses=[IP of the router]

what Ip would that be in my case?

Honestly, of all the possible questions, I really didn't expect this one.............

Hello rextended,

thank you for your reply.

At the moment, i want all devices to use only DoH.

Not sure, how to achieve this.

Hello teslasystems,

thank you for your reply. I will try to use wireshark soon.

:grimacing: i'm sry.

What is the IP of your router?

192.168.88.1

Simply: You can't do the way you think.

You'll need to manually configure all the devices that allow it,
but some will still want to use their hardcoded Chinese DNS, 8888/1111, etc.

At most, you can intercept calls to the cleartext DNS only, as much as possible, and redirect them to the router. The router then resolves them via DoH.

But all calls to non-standard DNS ports—DNScrypt, DNS over HTTPS, DNS over TLS, DNS over QUIK, etc.—will still pass.

At most, you can block DoT entirely on the standard port, or block all (know) DoH and DoQ via an address list, but you CANNOT redirect and resolve them.

so ip of the router refers to the default gateway of the bridge ?