AdGuardHome icon indicating copy to clipboard operation
AdGuardHome copied to clipboard

Binding to address 0.0.0.0 also binds to IPv6 interfaces

Open thenktor opened this issue 8 months ago • 3 comments

Prerequisites

Platform (OS and CPU architecture)

FreeBSD, AMD64 (aka x86_64)

Installation

Custom package (OpenWrt, HomeAssistant, etc; please mention in the description)

Setup

Other (please mention in the description)

AdGuard Home version

0.107.69

Action

Hi,

I'm running Adguard Home on a FreeBSD jail as nameserver. DHCP and other stuff is handled by other machines.

When binding DNS to IP 0.0.0.0 Adguard Home also listens on IPv6 addresses.

dns:
  bind_hosts:
    - 0.0.0.0
  port: 53

Log:

2026/03/09 13:43:14.491528 [info] dnsproxy: starting dns proxy server
2026/03/09 13:43:14.491544 [info] dnsproxy: creating udp server socket addr=0.0.0.0:53
2026/03/09 13:43:14.491665 [info] dnsproxy: listening to udp addr=[::]:53
2026/03/09 13:43:14.491672 [info] dnsproxy: creating tcp server socket addr=0.0.0.0:53
2026/03/09 13:43:14.491694 [info] dnsproxy: listening to tcp addr=[::]:53
2026/03/09 13:43:14.491772 [info] dnsproxy: entering udp listener loop addr=[::]:53
2026/03/09 13:43:14.491787 [info] dnsproxy: entering listener loop proto=tcp addr=[::]:53

Expected result

If I want Adguard Home to listen on IPv6 interfaces I would assume that I have to activate it:

dns:
  bind_hosts:
    - 0.0.0.0
    - '::'
  port: 53

Actual result

Additional information and/or screenshots

No response

thenktor avatar Mar 09 '26 13:03 thenktor

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

VsevolodNaumov avatar Jun 10 '26 16:06 VsevolodNaumov

I reproduced this on current AdGuard Home master (091d9287) with current dnsproxy master (acf2b30e). AdGuard Home correctly passes an IPv4-unspecified address to dnsproxy, but dnsproxy stringifies it and asks Go for the generic tcp / udp network. On dual-stack-capable systems, the resulting socket is [::]:port, matching the FreeBSD log in this report.

A deterministic regression against the real dnsproxy listener helpers fails on current master for both TCP and UDP because LocalAddr().IP is not IPv4. Selecting tcp4 / udp4 when the configured address is IPv4 fixes the test; the focused regression passed 20 times under -race, the full proxy package passed, and FreeBSD/Linux/macOS/Windows/OpenBSD vet checks passed.

Before publishing that dependency fix, there is one product-contract decision to reconcile with AdGuard Home PR #8490:

  • this issue expects 0.0.0.0 to be IPv4-only and IPv6 to require an explicit :: entry;
  • #8490 currently relies on DNS 0.0.0.0 retaining its existing dual-stack behavior and deliberately keeps it as the fresh-install DNS default, because adding both 0.0.0.0 and :: currently conflicts.

The tested dnsproxy change can implement the same asymmetric convention #8490 now uses for web listeners—explicit IPv4 addresses use tcp4 / udp4, while :: retains the generic dual-stack listener—but then fresh DNS defaults should use ::, and existing installations that implicitly relied on 0.0.0.0 for IPv6 need a documented migration decision. Alternatively, strict family semantics would require tcp6 / udp6 for :: and both addresses for dual-stack, which is a broader compatibility change.

Could maintainers confirm the intended wildcard contract and upgrade behavior? Once chosen, the implementation should be applied consistently to plain DNS and the DoT/DoQ listener paths, with real socket-family tests. I have kept the current test-first patch local rather than publishing a dependency PR that would silently choose one of these incompatible behaviors.

Sil3ntVip3r avatar Aug 03 '26 16:08 Sil3ntVip3r

One additional relationship sharpens the compatibility decision above: #5693 documents the prior maintainer contract that 0.0.0.0 means “all interfaces and all protocols” on dual-stack hosts, even when socket tools display [::].

Current dnsproxy still follows that contract, and the listener accepts both address families where the platform supports IPv4-mapped IPv6. Therefore the behavior in this report is real, but it is not merely an accidental socket regression: making 0.0.0.0 IPv4-only would deliberately reverse a documented compatibility promise.

That reinforces the need to decide and document wildcard semantics and upgrade behavior before changing dnsproxy. #8490's listener work should use the same decision so web, plain DNS, DoT, and DoQ do not acquire inconsistent meanings.

Sil3ntVip3r avatar Aug 05 '26 01:08 Sil3ntVip3r