Skip to content
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

feat: add a Dnsmasq upstream resolver filtering option #3923

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

alryaz
Copy link

@alryaz alryaz commented Feb 11, 2025

This allows for filtering of upstream responses (A and AAAA separately). Quite useful when the ISP does not support IPv6, and the router used does not support AAAA filtering.

Filtering of A responses is added solely for completeness.

P.S. It must be mentioned that the option should be named filter_AAAA solely for correctness purposes, not filter_aaaa; however YAML lowercase keying imposes styling constraints.

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features
    • Introduced new configuration options to control DNS filtering. Administrators can now choose to disable responses for IPv4 (A) and IPv6 (AAAA) records from upstream resolvers, with filtering turned off by default for legacy behavior.
    • Enhanced configuration capabilities with new options filter_a and filter_aaaa in the settings.
    • Added conditional configurations filter-A and filter-AAAA to enhance DNS record filtering.

Copy link
Contributor

coderabbitai bot commented Feb 11, 2025

📝 Walkthrough

Walkthrough

The pull request introduces two new configuration options for the Dnsmasq service to filter A and AAAA DNS records. The changes add boolean flags with default values set to false in the primary configuration file and update the schema accordingly. Additionally, conditional directives based on these flags have been incorporated into the templated configuration file, and corresponding user-facing translations with descriptive text have been added.

Changes

Files Change Summary
dnsmasq/config.yaml, dnsmasq/translations/en.yaml Added new boolean options filter_a and filter_aaaa (default: false) with schema/type updates in config.yaml and corresponding name/description entries in en.yaml.
dnsmasq/rootfs/…/dnsmasq.config Added conditional configuration entries filter-A and filter-AAAA that are applied when the corresponding boolean flags evaluate to true.

Sequence Diagram(s)

sequenceDiagram
    participant CF as Config (config.yaml)
    participant TE as Template Engine (dnsmasq.config)
    participant DS as DNS Service
    participant TR as Translations (en.yaml)

    CF->>TE: Provide options (filter_a & filter_aaaa flags)
    TE->>DS: Apply conditional directives ("filter-A"/"filter-AAAA")
    DS->>TR: Load translation strings for filter options
Loading

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 90486ed and a19f785.

📒 Files selected for processing (1)
  • dnsmasq/translations/en.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • dnsmasq/translations/en.yaml

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @coderabbitai title anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@agners
Copy link
Member

agners commented Feb 12, 2025

Why would you filter AAAA responses?

A properly working application should not pick the AAAA address if your host does not have a globally routable IPv6 address assigned. If you have problems with AAAA responses, that likely means your IPv6 setup is actually broken (e.g. you have a global IPv6 address assigned but it is not routed).

@alryaz
Copy link
Author

alryaz commented Feb 12, 2025

Why would you filter AAAA responses?

A properly working application should not pick the AAAA address if your host does not have a globally routable IPv6 address assigned. If you have problems with AAAA responses, that likely means your IPv6 setup is actually broken (e.g. you have a global IPv6 address assigned but it is not routed).

There may be lack of IPv6 on WAN egress, and IPv6 may still be used within LAN (for ARP-less communication). While not globally routable, a host may assume IPv6 WAN routing is available due to presence of a default nexthop, and thus attempt to utilize the address.

There are also rare cases of ISPs blocking border-crossing traffic (which is weird, however I've come across four instances of such over the past decade).

There's a case to be made for end users, who would probably be keen on pointing their router's DNS towards HA's Dnsmasq instance and solve the IPv6 issue that way (especially when disabling IPv6 isn't available on some ISP hardware).

Edit: IPv4-only VPNs may also cause problems. If a globally routed IPv6 is available, it could potentially bypass routes set up by an interface, thus causing hosts to potentially leak traffic.

@agners
Copy link
Member

agners commented Feb 12, 2025

There may be lack of IPv6 on WAN egress, and IPv6 may still be used within LAN (for ARP-less communication). While not globally routable, a host may assume IPv6 WAN routing is available due to presence of a default nexthop, and thus attempt to utilize the address.

Sure, IPv6 in link-local addresses and ULA addresses can be assigned. But any correctly implemented IP client program should try all addresses returned by the DNS (just like this tcp_connect.c example). In fact, it seems that by default, getaddrinfo does order the IP address according to what is available locally. In a quick test, getaddrinfo on a system which only has link-local addresses and ULA actually returned the IPv4 address first already, so even a "wrongly" implemented client should do "the right thing".

If IPv6 address filtering is required on DNS level, then this hints to a seriously broken IPv6 address configuration (e.g. by manually configure global addresses which in the end are not routed and/or a router which hands out IPv6 and then blocks traffic still).

There's a case to be made for end users, who would probably be keen on pointing their router's DNS towards HA's Dnsmasq instance and solve the IPv6 issue that way (especially when disabling IPv6 isn't available on some ISP hardware).

If ISPs provide such fucked up IPv6 implementation, they should complain with the ISP or switch to a sane ISP 🤷

Edit: IPv4-only VPNs may also cause problems. If a globally routed IPv6 is available, it could potentially bypass routes set up by an interface, thus causing hosts to potentially leak traffic.

But then fixing the problem on DNS level seems wrong. If something resolves an address somehow differently traffic still might get the wrong way. This seems like it needs a firewall solution.

I am fine merging this, but can we add a hint that this typically should not be required ans hints to a IPv6 misconfiguration of some sort?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants