Fix DNS timeouts against [::1]:53 on dual-stack networks
The core diagnosis is right: systemd-resolved's stub binds 127.0.0.53:53 and 127.0.0.54:53 and never ::1, so a hand-written nameserver ::1 times out. Both symlink targets named (stub-resolv.conf vs resolv.conf) are the two real supported layouts. The last block contradicts its own framing: it says 'prefer IPv4 for resolution rather than disabling IPv6 system-wide' and then gives ipv6.method disabled, which disables IPv6 outright on that connection. That is the exact thing it just told the user not to do. Preferring IPv4 for *resolution* is a getaddrinfo precedence setting.
Disabling IPv6 per-connection is a workaround, not a fix. Do not disable IPv6 globally via sysctl on networks that are IPv6-only.
Symptom
On native dual-stack networks (mobile hotspot, Starlink) name resolution intermittently times out. Tools that print resolver details show queries going to the IPv6 loopback:
dial tcp: lookup proxy.golang.org on [::1]:53: read udp [fe80::...]:43058->[::1]:53: i/o timeout
Users end up disabling IPv6 entirely to get anything working.
Cause
systemd-resolved's stub listener binds 127.0.0.53:53 (and 127.0.0.54:53). It does **not** listen on ::1. If /etc/resolv.conf is a hand-written file containing nameserver ::1, or an application falls back to ::1 because /etc/resolv.conf is not the resolved stub file, every query is sent to a port nothing is listening on and times out.
Fix
ls -l /etc/resolv.conf
sudo ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf
cat /etc/resolv.conf # must show: nameserver 127.0.0.53
sudo systemctl restart systemd-resolved
resolvectl flush-caches
resolvectl status | head -20
If you need every consumer to see the real upstream servers rather than the stub:
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
If AAAA lookups themselves are slow on that network, prefer IPv4 *results* without turning IPv6 off. Edit /etc/gai.conf and uncomment/add:
precedence ::ffff:0:0/96 100
That only reorders getaddrinfo results. IPv6 connectivity stays up. Reserve nmcli connection modify "<SSID>" ipv6.method disabled for the case where you really do want IPv6 off on that one network, and be aware it is not a DNS fix.
Verify
cat /etc/resolv.conf shows nameserver 127.0.0.53. resolvectl query proxy.golang.org returns A and AAAA records immediately, and ss -lunp | grep ':53' shows resolved bound on 127.0.0.53.