-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Proper EDNS handling and cleaner NOERROR response in DNSSERVER #11411
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
👋 Hello Kolkman, we appreciate your contribution to this project! 📘 Please review the project's Contributions Guide for key guidelines on code, documentation, testing, and more. 🖊️ Please also make sure you have read and signed the Contributor License Agreement for this project. Click to see more instructions ...
Review and merge process you can expect ...
|
@@ -1,5 +1,5 @@ | |||
name=DNSServer | |||
version=3.2.0 | |||
version=3.3.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this version is updated with every new release. Please revert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted the change with new commit
@@ -9,6 +9,23 @@ | |||
#define DNS_OFFSET_DOMAIN_NAME DNS_HEADER_SIZE // Offset in bytes to reach the domain name labels in the DNS message | |||
#define DNS_DEFAULT_PORT 53 | |||
|
|||
#define DNS_SOA_MNAME_LABEL "ns" | |||
#define DNS_SOA_RNAME_LABEL "esp32" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are MNAME and RNAME? How are their values chosen?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MNAME and RNAME are values defined in RFC1035 section 3.1.13.
Tne MNAME is the name of the primary nameserver the request came from - that value is only used in the context of dynamic DNS updates RFC 2136. In this contexts it is purely informational. I chose the 'ns' label as that is sort of customary for nameservers.
The RNAME is used to construct the email address of the administrator for the zone. The way things are coded now that is esp32@local. There nothing in the DNS protocol that uses that value, it is only for network administrator information siganling purpose.
// definition of RFC1035 3.1 | ||
// for instance, a postfix of example.com would be defined as: | ||
// #define DNS_SOA_POSTFIX_LABEL {'\7', 'e', 'x', 'a', 'm', 'p', 'l', 'e', '\3', 'c', 'o', 'm', '\0'} | ||
#define DNS_SOA_POSTFIX_LABEL {'\5', 'l', 'o', 'c', 'a', 'l', '\0'} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.local
is used by MDNS. Is that the best value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent question, because it surfaces a dilemma that I had.
Here are the considerations:
- The MNAME and RNAME are purely informational still you do not want something to be used on the real Internet.
- But, suppose that somebody queries a DNSSERVER on an ESP and decides to complain to the admin who is indicated in the RNAME. Then you don't want that mail to end up with an existing person somewhere on the Internet.
- The domains in the MNAME and RNAME could be based on the queryname, but that would be problematic for wildcard resolution, where the administrator email might become esp32@captive.apple.com, so I figure that is a bad choice.
- One has to pick a value that is never going to appear in the real DNS. The IANA maintains a registry of those.
- I think
invalid
might be a good choice. RFC 6761 says that trying to resolveinvalid
must always expected to fail. However - folk seeing 'invalid' in their soa record during troubleshooting might misinterpret what is happening. - .local demonstrates that something local is going on - which is the most likely place where ESP32s get deployed.
As said, there is nothing in the DNS (except for dynamic updates) that will use the M- and RNAME values, hence no interference with MDNS - the values are purely used in the context of local troubleshooting.
reverting version number update - as it is done automatically
Description of Change
Bugs
The code solves two bugs:
BUG 1: When trouble shooting a dnsserver with the 'dig' (one of the main DNS troubleshooting tools) the server doesn't answer because it doesn't handle EDNS (OPT records in the additional section).
That has been fixed, the additional section in the query can safely be ignored.
(mostly change around line 123)
BUG 2: The code also returns an A record when the QUERY Type not 'A' (or 'ANY').
This has been fixed too. For an A and ANY query type the server returns an A record.
(mostly change around line 114)
Feature
The code continues to return a 'SERVFAIL' when no match with QNAME occurs. However, with the fix of bug 2 we created a proper 'No Data' response, (RFC2308 2.2) for queries that have a match for the name, but not for the type. The function DNSServer::replyWithNoAnsw implements that functionality.
The server now behaves somewhat more conform the DNS protocl specifications.
(most of the code changes)
Tests scenarios
I tested this code on an ESP32 and WireShark as protocol analyzer - there is no reason to suspect that it does not work on other platforms (to which I have no access).
Related links