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

DNS/Filter Rewrite Behavior Change #6226

Closed
4 tasks done
DrDoug88 opened this issue Sep 16, 2023 · 9 comments
Closed
4 tasks done

DNS/Filter Rewrite Behavior Change #6226

DrDoug88 opened this issue Sep 16, 2023 · 9 comments
Assignees
Milestone

Comments

@DrDoug88
Copy link

Prerequisites

Platform (OS and CPU architecture)

Linux, AMD64 (aka x86_64)

Installation

Docker

Setup

On one machine

AdGuard Home version

v0.107.36

Action

A DNS lookup

Expected result

It should resolve to the selected IP in the DNS rewrites table.

Actual result

It resolved to a different IP.

Additional information and/or screenshots

I have been using AdGuardHome for the past year, and upgraded through various versions along the way. However, this most recent upgrade from v0.107.36 to v0.107.38 seems to have caused some issues. (Looking at the AGH releases, it was likely v0.107.37 where the logic changed). Anyhow, I am using a split-horizon DNS setup, stretching out a single base domain name with multiple destinations. Here is the specific issue:

DNS Rewrites Table:

example.com			1.2.3.4
*.example.com			1.2.3.4
*.external.example.com		A
*.internal.example.com		5.6.7.8

With v0.107.36 and prior, this logic worked fine. Even with the wildcard, if resolving abc.internal.example.com, it would return 5.6.7.8, while abc.example.com would resolve to 1.2.3.4.

However, with v0.107.38, abc.internal.example.com returns 1.2.3.4. It appears as if it is finding *.example.com first in the lookup process rather than *.internal.example.com.

Was this change intentional? If so, could there be an option to revert to the prior logic?

Thank you for all of your hard work.

@codyjd1
Copy link

codyjd1 commented Sep 17, 2023

I have the same issue.
For now i have done abc.example.com for all external (instead of wildcard), and *.internal.example.com for internal. But the rewrite table worked fine for me as well before V0.107.37 with the same wildcard setup as you @DrDoug88.

@DrDoug88
Copy link
Author

Thank you for confirming @codyjd1.

It works fine this way in Dnsmasq, i.e.

address=/.example.com/1.2.3.4
address=/.internal.example.com/5.6.7.8
server=/.external.example.com/<IP of AdGuardHome>
server=<IP of AdGuardHome>

So in the worst case, I'll have to use Dnsmasq as primary DNS server for host to intercept those requests, and then pass everything else to upstream AdGuardHome. But I wish I didn't have to, since I have already designed functions that access AGH's API to add/remove rewrite entries...

@codyjd1
Copy link

codyjd1 commented Sep 17, 2023

Thank you @DrDoug88 for the example appreciate it! For now i will probably keep mine as is but hoping its fixed in the future back to how it was, as I had no issues prior to V0.107.37. I hope as well if we can get some clarification on what has changed or easier workaround.

@ainar-g ainar-g added the needs investigation Needs to be reproduced reliably. label Sep 19, 2023
@ainar-g ainar-g added this to the v0.107.39 milestone Sep 19, 2023
@EugeneOne1 EugeneOne1 added bug P3: Medium and removed needs investigation Needs to be reproduced reliably. labels Sep 19, 2023
@EugeneOne1
Copy link
Member

@DrDoug88, hello and thanks for a thorough report and a test case. It's indeed a bug and we're going to release the fix in the edge channel later today.

adguard pushed a commit that referenced this issue Sep 19, 2023
Merge in DNS/adguard-home from 6226-legacy-rewrite-sort to master

Updates #6226.

Squashed commit of the following:

commit e47e8c9
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 19 17:16:43 2023 +0300

    all: imp log of changes

commit e551a74
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 19 16:29:46 2023 +0300

    all: fix alphabetical order

commit 2ce10c7
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 19 16:28:08 2023 +0300

    all: log changes

commit 545dd70
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 19 16:25:13 2023 +0300

    filtering: fix sort
@EugeneOne1
Copy link
Member

@DrDoug88, hello again. We've pushed the newest edge build that should fix the legacy rewrites priority. Could you please check if it does?

@DrDoug88
Copy link
Author

@EugeneOne1 Thank you for addressing this so quickly! Yes, I pulled the most recent edge build and it works as before. Closing.

@mxbchr
Copy link

mxbchr commented Oct 15, 2023

I'm experiencing this issue since I've updated to V0.107.39. Release notes link this issue and say it has been addressed.

I have set a few DNS rewrites so that the selfhosted services can be accessed by there internal IP while I'm home. Most services are run through a reverse proxy at 10.0.2.8 with hostname *.example.org, only the vnp server is hosted on 10.0.2.1 with hostname vpn.example.org.
So I set the rules:

||example.org^$client=10.0.2.0/24|192.168.3.0/24,dnsrewrite=NOERROR;A;10.0.2.8
||vpn.example.org^$client=10.0.2.0/24|192.168.3.0/24,dnsrewrite=NOERROR;A;10.0.2.1

This worked perfectly fine until a few hours ago. anything.example.org returned 10.0.2.8, vpn.example.org returned 10.0.2.1.
Now the DNS query suddenly gives back two A records:

"Non-authoritative answer:
Name: vpn.example.org
Address: 10.0.2.1
Name: vpn.example.org
Address: 10.0.2.8"

Setting the rule to:
||vpn.example.org^$client=10.0.2.0/24|192.168.3.0/24,dnsrewrite=NOERROR;A;10.0.2.1,important
does not solve the issue.

Neither does:
@@||vpn.example.org^$dnsrewrite=10.0.2.8
||vpn.example.org^$client=10.0.2.0/24|192.168.3.0/24,dnsrewrite=NOERROR;A;10.0.2.1
both with and without important modifier.

Details from query log:
"Response details
Status: Rewritten
Elapsed: 0.15 ms
Response code: NOERROR
Rule(s):
||vpn.example.org^$client=10.0.2.0/24|192.168.3.0/24,dnsrewrite=NOERROR;A;10.0.2.1
||example.org^$client=10.0.2.0/24|192.168.3.0/24,dnsrewrite=NOERROR;A;10.0.2.8
Custom filtering rules

Response:
A: 10.0.2.1 (ttl=10)
A: 10.0.2.8 (ttl=10)"

I feel like this is related to this issue/the fix.
@EugeneOne1 Is someone gonna reopen it or should I open a separate Issue?

@ppfeufer
Copy link

Try:

||example.org^$client=10.0.2.0/24|192.168.3.0/24,dnsrewrite=NOERROR;A;10.0.2.8
|vpn.example.org^$client=10.0.2.0/24|192.168.3.0/24,dnsrewrite=NOERROR;A;10.0.2.1

@mxbchr
Copy link

mxbchr commented Oct 15, 2023

Try:

||example.org^$client=10.0.2.0/24|192.168.3.0/24,dnsrewrite=NOERROR;A;10.0.2.8
|vpn.example.org^$client=10.0.2.0/24|192.168.3.0/24,dnsrewrite=NOERROR;A;10.0.2.1

Did so, thanks. But it doesn't change anything unfortunately.

Neither did either one of these:
@@||vpn.example.org^$dnsrewrite=NOERROR;A;10.0.2.8,important
@@||vpn.example.org^$dnsrewrite=10.0.2.8,important
@@||vpn.example.org^$client=10.0.2.0/24|192.168.3.0/24,dnsrewrite=NOERROR;A;10.0.2.1
@@||vpn.example.org^$dnsrewrite=10.0.2.8,client=10.0.2.0/24
plus
||vpn.example.org^$client=10.0.2.0/24,dnsrewrite=NOERROR;A;10.0.2.1

annguyen0 pushed a commit to annguyen0/AdGuardHome that referenced this issue Nov 27, 2023
Merge in DNS/adguard-home from 6226-legacy-rewrite-sort to master

Updates AdguardTeam#6226.

Squashed commit of the following:

commit e47e8c9
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 19 17:16:43 2023 +0300

    all: imp log of changes

commit e551a74
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 19 16:29:46 2023 +0300

    all: fix alphabetical order

commit 2ce10c7
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 19 16:28:08 2023 +0300

    all: log changes

commit 545dd70
Author: Eugene Burkov <E.Burkov@AdGuard.COM>
Date:   Tue Sep 19 16:25:13 2023 +0300

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

No branches or pull requests

6 participants