From a0482a4e35b5e96cfd7e65e8a60b300a94230aee Mon Sep 17 00:00:00 2001 From: "Jiri Slaby (SUSE)" Date: Tue, 17 Jan 2023 10:24:31 +0100 Subject: [PATCH] core: nm-dns-dnsmasq: listen on ipv6 localhost too Trying to resolve hosts using localhost errors out for ipv6 attempts: $ host www.seznam.cz localhost ;; communications error to ::1#53: connection refused ;; communications error to ::1#53: connection refused Using domain server: Name: localhost Address: 127.0.0.1#53 Aliases: www.seznam.cz has address 77.75.77.222 www.seznam.cz has address 77.75.79.222 ;; communications error to ::1#53: connection refused ;; communications error to ::1#53: connection refused www.seznam.cz has IPv6 address 2a02:598:a::79:222 www.seznam.cz has IPv6 address 2a02:598:2::1222 ;; communications error to ::1#53: connection refused ;; communications error to ::1#53: connection refused It's because on some distros (like openSUSE), localhost is defined both as 127.0.0.1 and ::1. So listen on ::1 too. This makes ipv4-switchoff easier. /etc/resolv.conf should likely be updated to contain ::1 eventually too (see update_dns()). Fixes https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1188 --- src/core/dns/nm-dns-dnsmasq.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/dns/nm-dns-dnsmasq.c b/src/core/dns/nm-dns-dnsmasq.c index 8e3c10c98c..cc0a878843 100644 --- a/src/core/dns/nm-dns-dnsmasq.c +++ b/src/core/dns/nm-dns-dnsmasq.c @@ -521,9 +521,10 @@ _gl_pid_spawn_next_step(void) argv[argv_idx++] = "--no-resolv"; /* Use only commandline */ argv[argv_idx++] = "--keep-in-foreground"; argv[argv_idx++] = "--no-hosts"; /* don't use /etc/hosts to resolve */ - argv[argv_idx++] = "--bind-interfaces"; + argv[argv_idx++] = "--bind-dynamic"; argv[argv_idx++] = "--pid-file=" PIDFILE; - argv[argv_idx++] = "--listen-address=127.0.0.1"; /* Should work for both 4 and 6 */ + argv[argv_idx++] = "--listen-address=127.0.0.1"; + argv[argv_idx++] = "--listen-address=::1"; argv[argv_idx++] = "--cache-size=400"; argv[argv_idx++] = "--clear-on-reload"; /* clear cache when dns server changes */ argv[argv_idx++] = "--conf-file=/dev/null"; /* avoid loading /etc/dnsmasq.conf */