AdGuardHome icon indicating copy to clipboard operation
AdGuardHome copied to clipboard

HTTPS record rewrite with $dnsrewrite not working

Open showgood163 opened this issue 9 months ago • 10 comments

Prerequisites

Platform (OS and CPU architecture)

Linux, ARMv7

Installation

GitHub releases or script from README

Setup

On one machine

AdGuard Home version

v0.107.72

Action

  1. Add one HTTPS record rewrite rule

||what.ever^$dnsrewrite=NOERROR;HTTPS;1 . ech=AEX+DQBBggAgACCkxcdxouv8w8QtgUzpnhDg0FT8qOyZ2HqSGwogCZdnBQAEAAEAAQASY2xvdWRmbGFyZS1lY2guY29tAAA=

  1. Use an dns query utility, e.g. https://github.com/natesales/q, to test the record
q https what.ever

Expected result

Return the correct HTTPS record.

Actual result

Return nothing.

Additional information and/or screenshots

No response

showgood163 avatar Mar 03 '26 09:03 showgood163

I can reproduce this. I’ll forward it to the dev team.

VsevolodNaumov avatar Jun 11 '26 11:06 VsevolodNaumov

There are two issues here, one with the rule and one with AGH:

  1. The padding (=) makes the rule invalid. It's not actually necessary, so you should just remove it.
  2. AGH should be less strict about parsing Base64 with no padding. We'll fix that.

ainar-g avatar Jun 16 '26 18:06 ainar-g

Hi.

The ech key above is from the query of cloudflare-ech.com. For now it's ech="AEX+DQBBFgAgACCwNFLgRRTjCPoQPifC2po/IvrwYwTTzGDqxOmWREutYwAEAAEAAQASY2xvdWRmbGFyZS1lY2guY29tAAA=". If you write " it's an invalid rule. What's the recommend way of writing this?

showgood163 avatar Jun 16 '26 18:06 showgood163

Just remove the final = (or ==). Once we implement the change on our side, it should work.

ainar-g avatar Jun 16 '26 18:06 ainar-g

Thanks. I'll wait for a test on my side.

showgood163 avatar Jun 16 '26 18:06 showgood163

@showgood163, should be fixed on the Edge channel in versions v0.108.0-a.1320+922a7aaf and later.

ainar-g avatar Jun 18 '26 11:06 ainar-g

We'll close the issue for now.

ainar-g avatar Jul 03 '26 12:07 ainar-g

Sorry for the late reply and thanks for the update.

With final = removed, the ech rewrite function on v0.107.78 is working. However, now AdguardHome only return https record. All other records, e.g., A, AAAA, are overwritten to none.

Rule example (please replace what.ever with a valid domain name with A/AAAA records): ||what.ever^$dnsrewrite=NOERROR;HTTPS;1 . ech=AEX+DQBBggAgACCkxcdxouv8w8QtgUzpnhDg0FT8qOyZ2HqSGwogCZdnBQAEAAEAAQASY2xvdWRmbGFyZS1lY2guY29tAAA=

showgood163 avatar Jul 14 '26 02:07 showgood163

@showgood163, you need to limit the rule's action to one DNS type as well. See https://adguard-dns.io/kb/general/dns-filtering-syntax/#dnstype-modifier.

ainar-g avatar Jul 14 '26 10:07 ainar-g

Thanks. I think my initial problem is solved.

The HTTPS only record rewrite function works as expected with ||what.ever^$dnstype=HTTPS,dnsrewrite=NOERROR;HTTPS;1 . ech=AEX+DQBBRQAgACBxypBShIlPJy0+2DWoxw6B6dy/pq5RhFqcAy+R+D2DTAAEAAEAAQASY2xvdWRmbGFyZS1lY2guY29tAAA. I tested it in chrome browser, and it worked.

Another question, is it possible to do dynamic rewriting, e.g., the valid HTTPS record comes from the HTTPS record of another domain which updates constantly? I tested rewriting with CNAME record and dynamic rewriting didn't work when testing in chrome browser.

showgood163 avatar Jul 14 '26 11:07 showgood163