13

I just upgraded my Ubuntu 22.04 boxes to 23.10 and then to 24.04.

They stopped resolving DNS queries.

They are using systemd-resolved and resolvconf.

David
  • 3,431
  • Are you running dnsmasq? Show me the output of dpkg -l dnsmasq|tail -n 1 and grep -i stub /etc/systemd/resolved.conf. – heynnema Jul 09 '24 at 22:48
  • 1
    @heynnema, some boxes/VMs were, and others were not. The boxes that dnsmasq installed had it installed for kvm or docker. The issues, as below in my answer, were variously, 1. systemd-resolved was not installed/upgraded on 24.04, or the dns server entries were not properly set in either the interfaces or netplan config files (as appropriate), or both. – David Jul 10 '24 at 11:08

2 Answers2

14

If your /etc/resolv.conf file says your nameserver is 127.0.0.53 then you likely are using resolvconf and systemd-resolved.

1. Make sure your systemd-resolved is installed:

sudo apt install systemd-resolved

(You might need to temporarily change your /etc/resolv.conf to use a well known dns server directly, like Google's, 8.8.8.8, or CloudFlare's 1.1.1.1, or another one. Note: if installation was partially complete, you may need to do mv /etc/resolv.conf /etc/resolv.conf.orig if it is a symlink, and then add nameserver 1.1.1.1 to it, then don't forget to restore the symlink back once you have fixed the issue.)

2. Make sure your configuration files have references to dns servers in them.

For systems that use Debian style /etc/network/interfaces config files makes sure you have dns-nameservers set in the iface section. For example:

auto  eth0
iface eth0 inet static
  address   1.2.3.4 
  netmask   255.255.255.0
  gateway   1.2.3.1
  dns-nameservers  8.8.8.8

If you have a newer install you could instead be using Netplan. The config file is usually /etc/netplan/01-netcfg.yaml

network:
  version: 2
  renderer: networkd
  ethernets:
    enp1s0:
      addresses:
        - 1.2.3.4/24
      routes:
        - on-link: true
          to: 0.0.0.0/0
          via: 1.2.3.1
      nameservers:
        addresses:
          - 8.8.8.8
          - 1.1.1.1

3. Revert changes to resolv.conf

Backout any changes made in step 1. to your resolv.conf file. That is, the line with nameserver should just be nameserver 127.0.0.53

4. Restart services

Restart networking systemctl restart systemd-networking

Restart resolved systemctl restart systemd-resolved

David
  • 3,431
  • 1
    While this eventually, eventually, got past the problem; Why is it necessary? How does then network/dns just break? And for multiple people! I upgraded 3 pc-s. Only one exhibited this problem. – will Oct 06 '24 at 04:14
  • 1
    @will >> 1. "Why is it necessary?" >> Because Ubuntu uses systemd-resolved and resolvconf which communicate with various services via dbus. >> 2. "How does then network/dns just break?" >> Perhaps it is because dns resolvers where not properly set in the netplan or interfaces config. 24.04 upgraded all systems to use netplan IIRC. I upgraded over 100 servers to 24.04. Actually, you probably could move step one to between step 2 and 3, and probably skip editing the /etc/resolv.conf file altogether. – David Oct 14 '24 at 14:55
-2

i guess it should use dns specified on netplan config, so this most be a BUG ? anyway, i fixed like this:

change the symbolic link of the resolv.conf to other name:

sudo ln -sf /etc/resolv.custom.conf /etc/resolv.conf

then add your preferred name servers:

sudo nano /etc/resolv.custom.conf

like:

nameserver 8.8.8.8 nameserver 1.1.1.1

instantly solved without any other steps..this way DNS got saved permanently tested with latest ubuntu 24.04

Rickz
  • 1
  • 1
  • Please add to the answer what you did with that file. – David DE Aug 13 '24 at 17:22
  • edited my comment with explanation, changed the method since previous method was only a temp solution – Rickz Aug 20 '24 at 18:23
  • You are potentially signing yourself up for a world of pain and this does not fix the actual issue. You are attempting to circumvent Ubuntu's standard system defaults which use systemd and resolved. When you do a package upgrade, system, or service restarts your fix will get overwritten. The fix is to properly configure your netplan yaml or interfaces file, and let systemd and resolved do what they are supposed to be doing. – David Aug 24 '24 at 11:04