DNS entry is kept on /etc/resolv.conf after interface unplugged.
Summary: When on Wi-Fi and I plug a network interface, a new DNS server is added to /etc/resolv.conf
, that's good. But when I unplug it, the entry is kept on /etc/resolv.conf
, possibly leading to very slow DNS queries or even timeouts.
With more details:
- I'm using gnome 42, networkmanager 1.36.4-2 from Debian testing.
- I'm on Wi-Fi, it works,
/etc/resolv.conf
contains:
$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.1.254
nameserver fd0f:ee:b0::1
This configuration is the right one:
$ dig mdk.fr @192.168.1.254 +short
51.15.187.166
$ dig mdk.fr @fd0f:ee:b0::1 +short
51.15.187.166
And the routes are OK too:
$ ip r
default via 192.168.1.254 dev wlp59s0 proto dhcp metric 600
169.254.0.0/16 dev wlp59s0 scope link metric 1000
192.168.1.0/24 dev wlp59s0 proto kernel scope link src 192.168.1.147 metric 600
When I plug my phone (Pinephone running Mobian, itself running network-manager 1.36.4) over USB-C it automatically share its connection, I'm OK with this. Journals looks like this:
journalctl -fu NetworkManager
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6242] manager: (usb0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/4)
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6622] device (usb0): interface index 13 renamed iface from 'usb0' to 'enx12739e2c0a02'
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6799] device (enx12739e2c0a02): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6807] device (enx12739e2c0a02): carrier: link connected
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6821] settings: (enx12739e2c0a02): created default wired connection 'Connexion filaire 1'
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6822] device (enx12739e2c0a02): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6826] policy: auto-activating connection 'Connexion filaire 1' (fee8cfde-7ddc-3436-aae0-e8a6de31c696)
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6828] device (enx12739e2c0a02): Activation: starting connection 'Connexion filaire 1' (fee8cfde-7ddc-3436-aae0-e8a6de31c696)
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6829] device (enx12739e2c0a02): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6831] device (enx12739e2c0a02): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6834] device (enx12739e2c0a02): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:07 seraph NetworkManager[64256]: <info> [1651305547.6838] dhcp4 (enx12739e2c0a02): activation: beginning transaction (timeout in 45 seconds)
Apr 30 09:59:09 seraph NetworkManager[64256]: <info> [1651305549.7236] dhcp4 (enx12739e2c0a02): state changed new lease, address=10.66.0.92
Apr 30 09:59:09 seraph NetworkManager[64256]: <info> [1651305549.7275] device (enx12739e2c0a02): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:09 seraph NetworkManager[64256]: <info> [1651305549.7798] device (enx12739e2c0a02): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:09 seraph NetworkManager[64256]: <info> [1651305549.7800] device (enx12739e2c0a02): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:09 seraph NetworkManager[64256]: <info> [1651305549.7806] policy: set 'Connexion filaire 1' (enx12739e2c0a02) as default for IPv4 routing and DNS
Apr 30 09:59:09 seraph NetworkManager[64256]: <info> [1651305549.7885] device (enx12739e2c0a02): Activation: successful, device activated.
Apr 30 09:59:09 seraph NetworkManager[64256]: <warn> [1651305549.7895] dispatcher: (7) /etc/NetworkManager/dispatcher.d/99tlp-rdw-nm failed (failed): Script '/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm' exited with status 2.
Apr 30 09:59:09 seraph NetworkManager[64256]: <warn> [1651305549.8535] dispatcher: (9) /etc/NetworkManager/dispatcher.d/99tlp-rdw-nm failed (failed): Script '/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm' exited with status 2.
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.0986] device (enx12739e2c0a02): state change: activated -> unmanaged (reason 'removed', sys-iface-state: 'removed')
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.1255] dhcp4 (enx12739e2c0a02): canceled DHCP transaction
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.1256] dhcp4 (enx12739e2c0a02): activation: beginning transaction (timeout in 45 seconds)
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.1257] dhcp4 (enx12739e2c0a02): state changed no lease
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.1276] policy: set 'Frigo' (wlp59s0) as default for IPv4 routing and DNS
Apr 30 09:59:11 seraph NetworkManager[64256]: <warn> [1651305551.1692] dispatcher: (10) /etc/NetworkManager/dispatcher.d/99tlp-rdw-nm failed (failed): Script '/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm' exited with status 2.
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.6421] manager: (usb0): new Ethernet device (/org/freedesktop/NetworkManager/Devices/5)
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7187] device (usb0): interface index 14 renamed iface from 'usb0' to 'enx12739e2c0a02'
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7321] device (enx12739e2c0a02): state change: unmanaged -> unavailable (reason 'managed', sys-iface-state: 'external')
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7327] device (enx12739e2c0a02): carrier: link connected
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7334] settings: (enx12739e2c0a02): created default wired connection 'Connexion filaire 1'
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7336] device (enx12739e2c0a02): state change: unavailable -> disconnected (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7339] policy: auto-activating connection 'Connexion filaire 1' (fee8cfde-7ddc-3436-aae0-e8a6de31c696)
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7341] device (enx12739e2c0a02): Activation: starting connection 'Connexion filaire 1' (fee8cfde-7ddc-3436-aae0-e8a6de31c696)
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7342] device (enx12739e2c0a02): state change: disconnected -> prepare (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7343] device (enx12739e2c0a02): state change: prepare -> config (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7345] device (enx12739e2c0a02): state change: config -> ip-config (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7347] dhcp4 (enx12739e2c0a02): activation: beginning transaction (timeout in 45 seconds)
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7577] dhcp4 (enx12739e2c0a02): state changed new lease, address=10.66.0.92
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7590] device (enx12739e2c0a02): state change: ip-config -> ip-check (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7607] device (enx12739e2c0a02): state change: ip-check -> secondaries (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7609] device (enx12739e2c0a02): state change: secondaries -> activated (reason 'none', sys-iface-state: 'managed')
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7612] policy: set 'Connexion filaire 1' (enx12739e2c0a02) as default for IPv4 routing and DNS
Apr 30 09:59:11 seraph NetworkManager[64256]: <info> [1651305551.7665] device (enx12739e2c0a02): Activation: successful, device activated.
Apr 30 09:59:11 seraph NetworkManager[64256]: <warn> [1651305551.7669] dispatcher: (11) /etc/NetworkManager/dispatcher.d/99tlp-rdw-nm failed (failed): Script '/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm' exited with status 2.
Apr 30 09:59:11 seraph NetworkManager[64256]: <warn> [1651305551.7956] dispatcher: (13) /etc/NetworkManager/dispatcher.d/99tlp-rdw-nm failed (failed): Script '/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm' exited with status 2.
So it updates the routes and resolv.conf, and I'm happy with this:
$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.1.254
nameserver fd0f:ee:b0::1
nameserver 10.66.0.1
$ ip r
default via 10.66.0.1 dev enx12739e2c0a02 proto dhcp metric 100
default via 192.168.1.254 dev wlp59s0 proto dhcp metric 600
10.0.0.0/8 dev enx12739e2c0a02 proto kernel scope link src 10.66.0.92 metric 100
169.254.0.0/16 dev wlp59s0 scope link metric 1000
192.168.1.0/24 dev wlp59s0 proto kernel scope link src 192.168.1.147 metric 600
Finally if I unplug my phone:
journalctl -fu NetworkManager
Apr 30 10:01:26 seraph NetworkManager[64256]: <info> [1651305686.1499] device (enx12739e2c0a02): state change: activated -> unmanaged (reason 'removed', sys-iface-state: 'removed')
Apr 30 10:01:26 seraph NetworkManager[64256]: <info> [1651305686.2015] dhcp4 (enx12739e2c0a02): canceled DHCP transaction
Apr 30 10:01:26 seraph NetworkManager[64256]: <info> [1651305686.2015] dhcp4 (enx12739e2c0a02): activation: beginning transaction (timeout in 45 seconds)
Apr 30 10:01:26 seraph NetworkManager[64256]: <info> [1651305686.2016] dhcp4 (enx12739e2c0a02): state changed no lease
Apr 30 10:01:26 seraph NetworkManager[64256]: <info> [1651305686.2020] policy: set 'Frigo' (wlp59s0) as default for IPv4 routing and DNS
Apr 30 10:01:26 seraph NetworkManager[64256]: <warn> [1651305686.2875] dispatcher: (14) /etc/NetworkManager/dispatcher.d/99tlp-rdw-nm failed (failed): Script '/etc/NetworkManager/dispatcher.d/99tlp-rdw-nm' exited with status 2.
the routes gets updated propertly:
$ ip r
default via 192.168.1.254 dev wlp59s0 proto dhcp metric 600
169.254.0.0/16 dev wlp59s0 scope link metric 1000
192.168.1.0/24 dev wlp59s0 proto kernel scope link src 192.168.1.147 metric 600
But resolv.conf keep the old, now wrong, state:
$ cat /etc/resolv.conf
# Generated by NetworkManager
nameserver 192.168.1.254
nameserver fd0f:ee:b0::1
nameserver 10.66.0.1
Which is not good. By moving my laptop to different places I remember having found it in a state where there's too many nameservers in /etc/resolv.conf
, breaking the name resolution.