Change DNS after many upgrades (24.04.1 LTS)

I miss the old forum as I tried to search within Discourse but found nothing, but maybe I just do not know how as I am new (did like the old forum better).

Ubuntu Version:
Ubuntu 24.04.1 LTS (GNU/Linux 6.8.0-51-generic x86_64)

I recently notice my server is using the wrong DNS and no longer obeyed my setting.
And I guess this is due many upgrades as I still use the /etc/network/interfaces for network settings.

This is my current interfaces:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary buildin network interface (LOCAL)
auto enp1s0
iface enp1s0 inet static
    address 192.168.1.1
    netmask 255.255.255.0

# The secondery 3c905 network interface (INTERNET)
#auto enp4s7
#iface enp4s7 inet dhcp
auto enp3s7
iface enp3s7 inet dhcp
dns-nameservers 9.9.9.9 1.1.1.1

But if I check the /etc/resolv.conf the DNS from my internet provider has been set.
I though (but maybe wrong) this would be 9.9.9.9 and 1.1.1.1 as set in the config.

If I read about the resolv.conf I get to check either systemd-resolve or resolvectl, but these give:

systemd-resolve --status

systemd-resolve: command not found

resolvectl status

Command ‘resolvectl’ not found, but can be installed with:
apt install systemd-resolved

Any help on how to set the DNS correctly, not the one getting via dhcp of the internet provider?

PS … the tag is networking_wireless but this has nothing to do with wireless. It’s just networking.

Thanks,
Matthijs

Welcome to Discourse. The software is different, but many of the same people are here.

Is the file /etc/resolv.conf a stand-alone file, or is it a link to somewhere else, such as ../run/systemd/resolve/stub-resolv.conf ?

And what do you get when you run
cat /etc/resolv.conf

Seems stand-alone. But is overwritten at boot as I tried to change it.

ls -lah /etc/resolv.conf
-rw-r–r-- 1 root root 100 Jan 22 10:36 /etc/resolv.conf

cat /etc/resolv.conf
domain arnhem.chello.nl
search arnhem.chello.nl
nameserver 62.179.104.196
nameserver 213.46.228.196

And I do not want to use the above DNS as it gives sometimes problems.

That has me a bit puzzled. When I upgraded my own vps which uses /etc/network/interfaces, it installed systemd-resolved which I had to work around before I could get DNS to work. But in your case, it doesn’t appear to be running, or even installed. It might be worth checking that you don’t have any other DNS-setting software installed, such as Network Manager or bind, as something must be overwriting the settings on boot.

Otherwise, we’ll have to see if someone else can throw light on this.

do-release-upgrade should have transitioned you to systemd-networkd, the purpose of do-release-upgrade and update-manager (its GUI) is exactly to handle such transitions during upgrade (though in the case of ifupdwon (which handles /etc/network/interfaces) there is a conscious decision to not touch it even though it is deprecated and unsupported in Ubuntu, to not automatically move you to netplan and leave it to you to do a manual transition) yet the move from the (also deprecated) resolvconf to systemd-networkd should have happened)

How exactly did you do the upgrade on that system ?

I always do the do-release-upgrade as advised (not using any GUI). I know sometimes it asks to upgrade etc files, which I not always do. Could this be the reason?

So systemd-networkd is the way to go, would this be an easy installation or upgrade from ifupdown?

You would have to install systemd-networkd and netplan (if they are not already) and translate your ifupdown config into a netplan.yaml file … though this is a risky task to do remotely indeed, if you can not be physically around the server to use the console when you mess up something, I’d leave it as it is until you can … but you should make sure to replace resolvconf with systemd-resolved in any case (use resolvectl to set it up properly, be careful to not log out before it all works when doing it remotely)

netplan documentation can be found here:

https://netplan.readthedocs.io/en/stable/

1 Like

My /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

#Set manual ip address 241218
auto enp1s0
iface enp1s0 inet static
address 10.0.0.61
netmask 255.255.255.0
gateway 10.0.0.1
dns-nameservers 8.8.8.8 8.8.4.4 

while

# Generated by NetworkManager
search hsd1.pa.comcast.net
nameserver 75.75.75.75
nameserver 75.75.76.76
nameserver 2001:558:feed::1
# NOTE: the libc resolver may not support more than 3 nameservers.
# The nameservers listed below may not be recognized.
nameserver 2001:558:feed::2
nameserver 2601:985:d80:4b0:1e93:7cff:fe6b:7910

Gee, I guess code tags don’t work here like they did at UF.

Use 3 backticks ``` instead of the [code] [/code] tags.

Just a single ` before and after if you want to mark an expression inline eg. #!/bin/sh

1 Like

@him610, does your system obey the dns-nameservers 8.8.8.8 8.8.4.4 as you mention in the /etc/network/interfaces?

@matthys70
does your system obey the dns-nameservers 8.8.8.8 8.8.4.4 as you mention in the /etc/network/interfaces?

 $ nslookup google.com
Server:		75.75.75.75
Address:	75.75.75.75#53

Evidently not, looks like the Network Manager has priority if there is a conflict.

BTW how do I know for sure that /etc/network/interfaces is used, as it seems dns-nameservers is not used/obeyed?