AdguardTeam / AdGuardHome

Network-wide ads & trackers blocking DNS server
https://adguard.com/adguard-home.html
GNU General Public License v3.0
25.53k stars 1.83k forks source link

DNS rewrite rule is not working as expected. #4599

Closed hezhijie0327 closed 2 years ago

hezhijie0327 commented 2 years ago

Have a question or an idea? Please search it on our forum to make sure it was not yet asked. If you cannot find what you had in mind, please submit it here.

Prerequisites

Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

Issue Details

Expected Behavior

For example, example.org DNS record is 1.2.3.4. Use the following rewrite rules.

|example.org^$dnsrewrite=NOERROR;A;2.4.6.8
|example.net^$dnsrewrite=NOERROR;CNAME;example.org

The final answer of example.net is 1.2.3.4 not 2.4.6.8.

Actual Behavior

The final answer should be 2.4.6.8.

Screenshots

Screenshot:

Additional Information

ainar-g commented 2 years ago

Hello. AdGuard Home doesn't currently follow CNAME chains with dnsrewrite rules. You can mitigate that by adding the address of your AdGuard Home as the upstream for example.org:

[/example.org/]192.168.X.Y
hezhijie0327 commented 2 years ago

It's worked for most scenario. But if the rule contains a specific client, it will not effect.

|example.org^$client=CLIENT1,dnsrewrite=NOERROR;A;2.4.6.8
|example.net^$client=CLIENT1,dnsrewrite=NOERROR;CNAME;example.org

This will break the query from other clients. [/example.org/]192.168.X.Y this should be the work around solution, is there any plan to let dnsrewrite support it?

ainar-g commented 2 years ago

You can use client-specific upstream settings for that. Although that might cause caching issues, see AdguardTeam/dnsproxy#169.

The CNAME chains will probably be implemented during #2499. I'll merge this feature request into that one.

rfgamaral commented 1 year ago

@ainar-g Any plans on implementing this feature soon? The upstream dns work around doesn't work for me, because I need these rules to be applied to specific clients only, and not all of them.