Resolving 'Temporary failure in name resolution' on Pi OS 12 Bookworm

Raspberry Pi OS version 12 (based on Debian 12 Bookworm) uses NetworkManager instead of dhcpcd for managing network connections, DNS resolution settings, DHCP, etc.

I've already mentioned using nmcli and nmtui for managing WiFi settings, but I ran into a strange issue after installing Docker on a fresh Raspberry Pi OS installation today. Suddenly DNS stopped working.

Trying to ping anything on the Internet gave me:

$ ping www.google.com
ping: www.google.com: Temporary failure in name resolution

As always, It was DNS. It was like DNS just gave up the ghost! Trying to change settings via nmtui seemed to not work (I tried DHCP for IPv4 with manual DNS, and that wasn't working).

Luckily, I found this post and followup comments mentioning the proper nmcli incantation to override DNS settings for an interface, so here it is (assuming built-in Ethernet):

$ sudo nmcli device mod eth0 ipv4.dns "8.8.8.8 8.8.4.4"
Connection successfully reapplied to device 'eth0'.

But you'll still need to restart NetworkManager for the change to take effect:

$ sudo systemctl restart NetworkManager

Now DNS works. I will have to do some more digging into why Docker seems to have eaten my DNS. This particular Pi is doing a couple interesting network-related things though, sooo... I can't lay all the blame on Docker. It may be that some of Docker's virtual networking blew up a configuration I had made earlier :)

Comments

Thanks for posting. I am missing a mention to your "It was DNS" merch.

Instead of restarting NetworkManager it should be sufficient to reset the network connection. It takes two commands, but leaves any other network devices active during the process.
> sudo nmcli device down eth0
> sudo nmcli device up eth0

Cheers!

The only problem with doing that is I was on a remote connection—which was working through eth0, so I could run the first command, but then wouldn't be able to get back in again to run the second! Restarting NM was brief enough that the connection re-established pretty easily.

Looking fwd to what you might find out. Even if it's due to a configuration you made, which kind of contradicts the "on a fresh installation" ;)

It may have been DNS but i smell a Red Shirt Jeff intrusion too...