dns: support an opt-in custom detection port - #3232
Merged
Merged
Conversation
Keep standard DNS, mDNS, and LLMNR port handling unchanged while allowing deployments with DNS on one explicitly configured port. The option is disabled by default and is covered by the official DNS-on-port-80 regression capture, including the expected classification output.
|
Member
|
Thank you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Related issue
Fixes #1788
Summary
DNS detection is currently restricted to the standard DNS, mDNS, and LLMNR ports. This prevents nDPI from recognizing valid DNS traffic deployed on a user-selected nonstandard port. The behavior was confirmed in the issue discussion and reproduced with the official
dns_on_port_80.pcapngcapture.This pull request adds an explicit, disabled-by-default configuration parameter that enables DNS detection on one additional exact TCP or UDP port.
Configuration
The default value is
0, which keeps existing behavior unchanged. The accepted range is0through65535. Only the configured port is added to the DNS entry-point gate. Standard DNS on port 53, mDNS on port 5353, and LLMNR on port 5355 retain their existing handling.Implementation details
The DNS port classification helper now receives the nDPI configuration context and returns
NDPI_PROTOCOL_DNSonly when the configured custom port matches either flow endpoint. Existing DNS structural validation remains mandatory, so enabling a custom port does not classify arbitrary traffic solely because it uses that port.The configuration parameter is registered in
src/lib/ndpi_config.c, stored in the private configuration structure, and documented indoc/configuration_parameters.rst.Evidence and regression testing
The official issue capture is included as the positive regression fixture:
The same capture without the configuration remains
Unknown, confirming that the option is disabled by default. Standard DNS traffic remains classified as DNS when the option is enabled. An unrelated HTTP capture with port 80 produced no DNS classification. An invalid value of70000is rejected by the configuration API.The following checks passed locally:
The sanitizer run completed without an AddressSanitizer, UndefinedBehaviorSanitizer, or LeakSanitizer report.
Files changed
src/lib/protocols/dns.csrc/lib/ndpi_config.cdns.custom_portwith default0and range0to65535src/include/ndpi_private.hdoc/configuration_parameters.rsttests/cfgs/dns_custom_port/Checklist
References