AdguardTeam / AdguardTeam/AdGuardHome
Preserve subdomain in DNS Rewrite (e.g. [xyz].lan to [xyz].fritz.box)
- Dominant language
- TypeScript
- Stars
- 36.9k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
### Prerequisites
- [x] Discussed and suggested to file as feature request: https://github.com/AdguardTeam/AdGuardHome/discussions/4532
- [x] I am running the latest version
- [x] I checked the documentation and found no answer
- [x] I checked to make sure that this issue has not already been filed
### Problem Description
Many of us have routers which have non-configurable LAN domain names. e.g. `fritz.box`
We still use the router's DHCP, because it's helpful with router features (like setting up separate guest/trusted IP ranges, firewall rules, etc). Let's say we don't want to switch to AGH DHCP just for changing the lan domain name.
Can we rewrite `*.lan` to `*.fritz.box` using AGH, i.e. rewrite the TLD preserving subdomain? It would help all LAN devices internally talk via `.lan` domain, but the address resolution can still be done by the upstream router as `.fritz.box`.
### Proposed Solution
A way to "Preserve Subdomain" when doing DNS rewrite in the AdguardHome.
Some options are:
1. Add a special parameter in `$dnsrewrite` filter rule, e.g.
```
||home.lan^$dnsrewrite=[PRESERVE_SUBDOMAIN|TLD_ONLY];CNAME;fritz.box
```
2. (OR) Add regex replace support in `$dnsrewrite` filter rule, e.g.
```
||/(.+).home.lan/^$dnsrewrite=NOERROR;CNAME;$1.fritz.box
```
3. (OR) Add a checkbox like "Preserve Wildcard" in AGH "DNS Rewrites" screen
4. (OR) Add regex replace support in AGH "DNS Rewrites" screen

### Alternatives Considered
1. It's possible to add unbind or some other DNS resolver on top of AGH, but it's quite a bit of added complexity given that AGH already has good DNS Rewrite support (screen & filter).
2. To have AGH act as a DHCP server and use AGH's lan domain by default. But as explained above, there are good reasons to use the router's DHCP.
Contributor guide
Assessment
This issue has not been assessed yet.