Score:0

Changing DNS nameservers with systemd-resolve doesn't persist

am flag

let me start by saying that I'm not sure whether I'm running Ubuntu server or Ubuntu desktop, that being said, my 'server' is running on a VPS.

Here is the output of lsb_release -a:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.3 LTS
Release:    20.04
Codename:   focal

I'm trying to override the default DNS name servers, and I've half succeeded. I have run systemd-resolve --interface eth0 --set-dns 10.13.13.5 --set-domain test.test to set 10.13.13.5 as a nameserver for the domain test.test and then run service systemd-resolved restart. I can then ping devices on the test.test domain, having them resolve to the right IP address.

I can confirm the 10.13.13.5 nameserver is in effect by doing systemd-resolve --status.

It comes up with this:

Link 2 (eth0)
      Current Scopes: DNS            
DefaultRoute setting: yes            
       LLMNR setting: yes            
MulticastDNS setting: no             
  DNSOverTLS setting: no             
      DNSSEC setting: no             
    DNSSEC supported: no             
  Current DNS Server: 10.13.13.5   
         DNS Servers: 213.133.100.100
                      213.133.98.98  
                      213.133.99.99  
          DNS Domain: test.test

After a few minutes though, the server will not resolve domain names to any IP addresses on the test.test domain. The --status command above now looks like this:

Link 2 (eth0)
      Current Scopes: DNS            
DefaultRoute setting: yes            
       LLMNR setting: yes            
MulticastDNS setting: no             
  DNSOverTLS setting: no             
      DNSSEC setting: no             
    DNSSEC supported: no             
  Current DNS Server: 213.133.98.98  
         DNS Servers: 10.13.13.5     
                      213.133.100.100
                      213.133.98.98  
                      213.133.99.99  
          DNS Domain: test.test        

It's clear what the issue is here, the Current DNS Server is being changed... but I'm not sure what's changing it and I'm not sure how to stop it.

My /etc/resolv.conf file is linked to /run/resolvconf/resolv.conf:

lrwxrwxrwx 1 root root 29 May 19 15:30 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

I think I can slightly grasp the way it works although it does confuse me a little... the stub is 127.0.0.53, which is an internal DNS resolver to nameservers you specify in /run/systemd/resolve/resolv.conf, but I'm not sure if this is right.

I would greatly appreciate any help with this as it is annoying being able to resolve things for a few minutes and then they stop working!

Thanks in advance.

vn flag
Did you [try `nm-connection-editor`](https://askubuntu.com/a/557382/349837) or [`nmtui`](https://askubuntu.com/a/1174193/349837)?
nick avatar
am flag
Both commands not found.
vn flag
Does this answer your question? [How do I configure my DNS settings in Ubuntu server?](https://askubuntu.com/questions/346838/how-do-i-configure-my-dns-settings-in-ubuntu-server)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.