Community discussions

MikroTik App
 
jkroon
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 59
Joined: Thu Apr 03, 2008 2:18 am
Contact:

DNS doesn't fallback to TCP if response is indicated to be truncated

Mon Oct 16, 2023 3:34 pm

As per RFC 1034/1035 should a resolver (cache or client) receive a UDP response with the TC (truncated) bit set the query should be retried using TCP.

It seems that Mikrotik doesn't do this. The following snippet refers, where 192.168.42.1 is the Mikrotik in question (RoS 6.49.7) and 192.168.42.21 is the "upstream" cache (it in turn uses two upstream DJBDNS caches, but in this case already has the response cached):
13:59:23.326953 IP (tos 0x0, ttl 64, id 58536, offset 0, flags [none], proto UDP (17), length 99)
    192.168.42.1.51961 > 192.168.42.21.53: 4900+ TXT? selector-1697116436._domainkey.dejonghoptometry.co.za. (71)
So it sends the query as expected.
13:59:23.327060 IP (tos 0x0, ttl 64, id 60262, offset 0, flags [DF], proto UDP (17), length 540)
    192.168.42.21.53 > 192.168.42.1.51961: 4900| 3/0/0 selector-1697116436._domainkey.dejonghoptometry.co.za. TXT "v=DKIM1; k=rsa; t=s; n=core; p=MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEArpFccWmhLDrQZgRgnTbr9Z9WqY0A2w6oxOd/V5QrBFCVADXlZZWQ0797se6raOuo6TMts1rpVpqYloDd/B", selector-1697116436._domainkey.dejonghoptometry.co.za. TXT "9daBIhbFpB98J3uUsE3W4JUykVNxKwsNndRHTI9kmHTUQ7xqQ0MLf8wifpuHMBCEDNvU4LpwjTDZirG92X2d959T73b3BqbfdkwDPz+BOEk0p2ZZlMSaWJpEXVOgFDqfuFg", selector-1697116436._domainkey.dejonghoptometry.co.za. TXT [|domain]
There goes the truncated to 512 bytes (see below) response. Decoding this frame using wireshark gives the following flags:

Response bit: 1
Opcode: 0
Auth: 0
Truncated: 1
Recursion desired: 1
Recursion available: 1
Reserved: 0
Answer authenticated: 0
Non-authenticated data: 0
reply-code: 0 (no error)

Please note that for the above I hacked djbdns to truncate to 512 bytes rather than directly after the question section in the response (ie, normally it won't include even a part of the response). This was done in the hopes that it might trigger RouterOS to switch to TCP fallback.

Anyway, at this point RouterOS simply retransmits the request, somehow expecting a different result, instead of switching to TCP.

RouterOS itself will serve queries from TCP and itself truncate packets to configured size (default 4096 bytes, although the standard says to use 512, but then again with DNSSEC it's probably not a bad idea to violate this and ship larger responses in UDP, but that's a different discussion not relevant to this one) on UDP and set the Truncate bit, so it knows about this, but for some reason doesn't seem to act correctly when running as a client.

One thing we could do is to modify our caches to serve up to 4KB via UDP, but that would go against standards, as well as just move the goalpost (what happens when we get sufficient data to overflow the 4KB mark?)

Is there some configuration option I'm missing, or is this a bug in RouterOS that will be fixed some time soon?
 
User avatar
Amm0
Forum Guru
Forum Guru
Posts: 3786
Joined: Sun May 01, 2016 7:12 pm
Location: California

Re: DNS doesn't fallback to TCP if response is indicated to be truncated

Mon Oct 16, 2023 3:46 pm

This sounds like a bug. You might want to file it at help.mikrotik.com since you seem to have done your homework and Mikrotik may not see it here.
 
jkroon
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 59
Joined: Thu Apr 03, 2008 2:18 am
Contact:

Re: DNS doesn't fallback to TCP if response is indicated to be truncated

Mon Oct 16, 2023 5:45 pm

Done thanks.

Who is online

Users browsing this forum: Bing [Bot], esj and 29 guests