Skip to content

feat(system): apply the panel's DNS server to the OS resolver - #5658

Open
Hiddify-Official wants to merge 1 commit into
hiddify:devfrom
Hiddify-Official:feat/dns-presets
Open

Hiddify-Official wants to merge 1 commit into
hiddify:devfrom
Hiddify-Official:feat/dns-presets

Conversation

@Hiddify-Official

@Hiddify-Official Hiddify-Official commented Oct 31, 2026 •

Copy link
Copy Markdown

Problem

The panel's DNS Server setting only affected the proxy cores; the server's own OS resolver stayed on whatever the host was set to, so choosing an ad-blocking or family DNS in the panel did not apply to the server itself.

Change

  • scripts/common/run.sh.j2 (runs on every apply): parses dns_server (comma/semicolon separated), keeps valid IPv4/IPv6 entries, writes them to /etc/systemd/resolved.conf.d/hiddify-dns.conf (DNS=…, Domains=~.) and restarts systemd-resolved only when the file changed.
  • No valid IP left: the file is removed (and resolved restarted), so the host default comes back. Skipped in Docker mode.

Tested

  • main: apply with a preset, with a custom value containing an invalid entry and an IPv6 address, then the default: drop-in file, resolvectl dns and name resolution correct each time; nothing restarted when unchanged.
  • node1 / node2: full install, drop-in written with the default value, resolution working.
  • Template rendered locally and checked with bash -n.

Review

  • Confidence: Needs review — changes the host's resolver; please check the Domains=~. choice (makes this DNS the global default over per-link DHCP DNS) and the Docker skip.
  • Complexity: Complex — system service script, touches host networking; pairs with the panel PR.

Related: hiddify/hiddifypanel#160

🤖 Generated with Claude Code

On every apply, the IPs in dns_server (comma separated, invalid entries
ignored) are written to /etc/systemd/resolved.conf.d/hiddify-dns.conf
and systemd-resolved is restarted only when that file changed. With no
valid IP the file is removed and the system default comes back. Skipped
in Docker.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NR-Vortex

Copy link
Copy Markdown

This script runs for every non-Docker mode and unconditionally calls systemctl restart systemd-resolved. On hosts where systemd-resolved is not installed, enabled, or managed by another resolver, the command can fail and abort the rest of run.sh.j2. Could this be guarded with a service/command availability check, with a safe fallback or warning?

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants