diff --git a/networkManager.go b/networkManager.go index 05a0443..5622393 100644 --- a/networkManager.go +++ b/networkManager.go @@ -869,5 +869,18 @@ func (nm *networkManager) SetIfaceDNS(ctx context.Context, iface string, servers } } + // Put the resolvers into effect. Writing them to the profile alone leaves + // the running device on whatever it resolved through before, and the + // ignore-auto-dns above means that is now nothing at all where the old + // resolvers came from a lease -- a device holding an address, a route, and + // no way to resolve a name. Unlike turning a DHCP client off, this carries + // no risk for a caller connected over the interface: reapply changes the + // device in place and does not tear the link down. + if len(targets) != 0 { + if rerr := reapplyDevice(ctx, iface); rerr != nil { + logger.Printf("error applying the connection profile to %s: %v", iface, rerr) + } + } + return errors.Join(errs...) } diff --git a/tests/networkManager/results/1/test b/tests/networkManager/results/1/test index ebc2f46..6d7a0c1 100644 --- a/tests/networkManager/results/1/test +++ b/tests/networkManager/results/1/test @@ -4,3 +4,4 @@ connection modify test ipv4.routes 10.253.2.0/24 203.0.113.22 100 connection modify test ipv6.routes abcd:ef12:3455:10::/64 abcd:ef12:3456:10::1 100 connection modify test_eth0 ipv4.dns 8.8.8.8,1.1.1.1 ipv4.dns-search example.com ipv4.ignore-auto-dns yes connection modify test_eth0 ipv6.dns 2001:4860:4860::8888 ipv6.dns-search example.com ipv6.ignore-auto-dns yes +device reapply test_eth0 diff --git a/tests/networkManager/results/2/test b/tests/networkManager/results/2/test index 06ead3b..dda5457 100644 --- a/tests/networkManager/results/2/test +++ b/tests/networkManager/results/2/test @@ -4,6 +4,7 @@ connection modify test ipv4.routes 10.253.2.0/24 203.0.113.22 100 connection modify test ipv6.routes abcd:ef12:3455:10::/64 abcd:ef12:3456:10::1 100 connection modify test_eth0 ipv4.dns 8.8.8.8,1.1.1.1 ipv4.dns-search example.com ipv4.ignore-auto-dns yes connection modify test_eth0 ipv6.dns 2001:4860:4860::8888 ipv6.dns-search example.com ipv6.ignore-auto-dns yes +device reapply test_eth0 connection modify test_eth0 ipv4.method auto ipv4.addresses 1.2.10.4/24 ipv4.gateway 1.2.10.254 connection modify test_eth0 ipv6.method auto ipv6.addresses ipv6.gateway connection modify main ipv4.routes