Feature Request: Keyword Filtering with Label-Level Matching (No Regular Expressions)
Hello Team, [ & ]
Summary
I propose an optional Keyword Filtering tab in each configuration profile. A rule matches keywords against individual DNS labels at a chosen position relative to the registrable domain (determined with the Public Suffix List), using a selectable match mode, and blocks the matching hostnames.
The existing Denylist, Allowlist, Security, Privacy and Parental Control features stay unchanged. The proposal is split into two stages: a compact first stage that solves the core problem, and optional extensions that could follow later.
1. Problem
- Domain rotation. Some services keep registering new domains that contain a recognizable word (a community example:
hitclub.vip,taihitclub.xyz,hitclub-123.top). Keeping the Denylist current is manual, and blocklists lag behind new registrations. - Telemetry and analytics endpoints. Many sites serve such traffic from hostnames like
analytics.<site>ortelemetry.<site>. Blocking the registered domain breaks the site, and the Denylist cannot express “any host whose first-level label isanalytics”. Each hostname has to be listed individually.
NextDNS Denylist entries apply to a domain and all its subdomains (see the API documentation), and a TLD can be denied as well. What is missing is matching on a keyword inside a label at a defined position.
This request does not ask for regular expressions, URL-path filtering, HTTP-content filtering or any application-level filtering. The scope is limited to domain names visible in DNS queries.
Related community discussions:
- Feature Request: Keyword-based Wildcard Blocking in Denylist
- Regex in allow and deny list and logs search
- Blacklisting domain by regex
A comparable structured approach exists in KeeneticOS 5.2, which added a Keyword Filter tab for blocking domain names based on keyword groups.
2. Two Stages
- Stage 1 (core of this request): keyword rules, with level, match mode, depth, an audit-only mode, rule-scoped exceptions, logging and a preview function (sections 3 to 11).
- Stage 2 (optional, later): reusable keyword groups, several rules sharing a group, schedules and further scoping (section 12).
3. Stage 1: Rule Definition
Each rule contains:
- Name and optional description.
- One or more keywords.
- Label level (section 4).
- Match mode (section 5).
- Depth behavior (section 6).
- Action: Block or Log only (audit mode, see section 11).
- Optional rule-scoped exceptions: hostnames, together with their subdomains, that this rule must not affect.
- Enabled/disabled status.
4. Label Levels
The queried name is split into labels. The public suffix is identified with the Public Suffix List (PSL). The registrable domain is the public suffix plus one label, and levels are counted from there:
- Level 0: the registered-domain label (the label directly left of the public suffix).
- Level 1: the first-level subdomain label.
- Level 2, 3, …: further subdomain labels to the left.
- All levels: the registered-domain label and every subdomain label.
Assuming example.com is the registered domain:
example.com→ L0exampleanalytics.example.com→ L0example, L1analyticsapi.analytics.example.com→ L0example, L1analytics, L2apiv2.api.analytics.example.com→ L0example, L1analytics, L2api, L3v2
Public suffix handling:
- Public suffix labels (
com,com.tr,co.uk) are never evaluated as keyword targets. - Dot-counting is not reliable. For example,
analytics.example.com.trhascom.tras its suffix, so its L0 isexampleand its L1 isanalytics, whileanalytics.com.trhas L0analyticsand no L1. - The full PSL prevailing-rule algorithm (wildcard and exception rules, and the default rule for unlisted TLDs) should be used.
- ICANN vs PRIVATE section. The PSL has an ICANN section and a PRIVATE section. PRIVATE entries are added by domain owners who issue subdomains to mutually-untrusting parties (for example
github.io). I suggest using the ICANN section only by default, because it is more predictable. Under this default,analytics.github.iohas registered domaingithub.ioand L1analytics. If the PRIVATE section were included,analytics.github.iowould itself be a registered domain with L0analytics. Whichever choice is made, it should be documented, and ideally selectable. - The level numbering above is only a suggestion. Any equally clear scheme is acceptable.
5. Match Modes
Matching is case-insensitive (DNS names are case-insensitive for ASCII labels, RFC 4343) and is performed within a single label, never across the whole hostname. For the keyword analytics:
- Exact: the whole label equals the keyword.
analytics→ match;myanalytics,analytics2,my-analytics→ no match. - Starts with:
analytics,analytics2→ match;myanalytics,my-analytics→ no match. - Ends with:
analytics,myanalytics,my-analytics→ match;analytics2→ no match. - Word: the keyword equals a hyphen-delimited segment of the label.
analytics,my-analytics,analytics-eu→ match;myanalytics,analytics2→ no match. - Contains:
analytics,myanalytics,analytics2,my-analytics→ match.
Exact is the safest default. Real tracking hostnames are often compound labels (for example ads-api), which Exact would miss. This is why Word, Starts with and Ends with are included: they cover common patterns without the breadth of Contains.
Short keywords with Contains are dangerous. For example, ad would match download, adobe and gadget. The interface should warn about short keywords (for example under four characters) in Contains, Starts with and Ends with modes.
6. Depth
- Exact depth: the matching label must be the leftmost label of the queried name.
- Include deeper subdomains: the matching label may be followed by additional labels to its left.
For a rule at Level 1 with the keyword analytics:
- Exact depth:
analytics.example.com→ block;api.analytics.example.com→ no match. - Include deeper:
analytics.example.com,api.analytics.example.com,v2.api.analytics.example.com→ block.
At Level 0 with “Include deeper”, a rule effectively blocks every hostname under a registered domain whose label matches. With “All levels”, the depth setting is not applicable.
7. Worked Example
Rule: keywords analytics, tracking, tracker, telemetry; Level 1; Exact; Include deeper; Block.
analytics.example.com→ Block (L1 exact match)api.analytics.example.com→ Block (L1 match, deeper included)analytics.example.com.tr→ Block (suffixcom.tr; L1 match)myanalytics.example.com→ Allow (not an exact match)analytics.com→ Allow (keyword only at L0)analytics.com.tr→ Allow (suffixcom.tr; keyword only at L0)analytics.api.example.com→ Allow (keyword at L2; L1 isapi)
8. Evaluation Order and Exceptions
- The existing Allowlist behavior must stay as it is. The Allowlist banner currently states that allowing takes precedence over everything else, and Keyword Filtering should not change that.
- A keyword rule must never create global Allowlist or Denylist entries, and rule-scoped exceptions must not silently weaken unrelated protections.
- The order between Keyword Filtering and the other mechanisms (Denylist, Security, Privacy, Parental Control) should be deterministic and documented.
9. Normalization and Limits
- ASCII labels are compared case-insensitively.
- Trailing dots are ignored.
- Internationalized names are evaluated in their ASCII (A-label/Punycode) form, as the API already requires for Denylist entries. Partial matching on
xn--labels is not meaningful, so for internationalized labels an initial release could support Exact mode only. - A label is at most 63 octets (RFC 4343), which bounds the per-label work.
- Suggested limits: a maximum total number of keywords per profile, comparable to the existing Denylist limit, and a warning threshold for short keywords.
10. Implementation and Performance
Unrestricted regular expressions can be costly and hard to bound. This proposal avoids them:
- Parse the queried name into labels.
- Identify the registrable domain with the PSL.
- Select the configured label level.
- Compare the label with the configured keywords using the chosen mode.
- Apply the rule’s action.
All keywords of a profile can be compiled into a multi-pattern matcher (for example an Aho–Corasick automaton) when the configuration changes, together with a cached PSL lookup. The cost per query then depends only on the label length. Overhead should be benchmarked under realistic query volumes.
11. Logging, Audit Mode and Preview
- Logs should show when a query is blocked by Keyword Filtering, with the rule name, matched keyword, evaluated level and match mode.
- Log only (audit) mode records would-be matches without blocking, so a rule can be checked against real traffic before it is enforced.
- A preview/test function should let the user enter a hostname and see which rule would match and why, without changing filtering behavior. Previewing a rule against the profile’s recent logs would also help to spot unintended matches.
12. Stage 2: Possible Extensions
- Reusable keyword groups shared across several rules, each with its own level, mode and depth (groups define what to search for, rules define how and where).
- Schedules for individual rules.
- Per-device assignment. Since profiles can already be assigned to devices, the simplest option may be to keep rules per profile.
13. Compatibility
- Keyword Filtering is optional and disabled by default.
- Existing profiles must not be changed automatically.
- Denylist, Allowlist, Security, Privacy and Parental Control behavior must stay unchanged when the feature is disabled.
14. Open Questions for the Team
- Should keyword rules also be applied to names in a CNAME chain, or only to the queried name?
- Should the PSL PRIVATE section be included, excluded, or selectable?
- What should the evaluation order be relative to existing mechanisms?
- What keyword count limit is acceptable?
15. References
- NextDNS API documentation
- Public Suffix List
- RFC 4343: DNS Case Insensitivity Clarification
- KeeneticOS 5.2 release notes (Keyword Filter)
Conclusion
The goal is precise, predictable domain-label matching without regular expressions: keywords, a position in the domain hierarchy, a match mode, and good visibility in the logs. Even a Stage 1 implementation would let users block rotating and telemetry hostnames without maintaining long Denylists or blocking whole registered domains.
Thank you for considering this proposal. Feedback on technical feasibility and roadmap fit would be appreciated.
Reply
Content aside
-
1
Votes
- 3 hrs agoLast active
- 7Views
-
1
Following
