diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c index 7d180378b6..cd755b13d4 100644 --- a/src/resolve/resolved-dns-server.c +++ b/src/resolve/resolved-dns-server.c @@ -875,9 +875,18 @@ DnsServer *manager_get_dns_server(Manager *m) { manager_read_resolv_conf(m); /* If no DNS server was chosen so far, pick the first one */ - if (!m->current_dns_server) + if (!m->current_dns_server || + /* In case m->current_dns_server != m->dns_servers */ + manager_server_is_stub(m, m->current_dns_server)) manager_set_dns_server(m, m->dns_servers); + while (m->current_dns_server && + manager_server_is_stub(m, m->current_dns_server)) { + manager_next_dns_server(m, NULL); + if (m->current_dns_server == m->dns_servers) + manager_set_dns_server(m, NULL); + } + if (!m->current_dns_server) { bool found = false;