0

I have a two local DNS configured which sometimes works and sometimes it does not, using Ubuntu 20.04

I defined my local DNS with the GUI: enter image description here

Why it works sometimes and sometime not is very well explained in Local DNS dissapears from resolver after a while . The internet is slow, there is a timeout and access to the public DNS fails. So then next DNSnames server appears, which is my local DNS. And than I can access my local URL.

When executing systemd-resolve --status | sed -n '/DNS Servers/,/^$/p' I get:

DNS Servers: 10.0.2.3    
                      192.168.1.70
                      192.168.1.1 
          DNS Domain: ~.

But DNS server 10.0.2.3 I never defined, as far as I can recall.

When, again sometimes, my local DNS is used, everything works as desired. I can check this with:

resolvectl status

if it returns (I stripped the content a bit):

Link 2 (enp0s3)
      Current Scopes: DNS         
DefaultRoute setting: yes         
       LLMNR setting: yes         
MulticastDNS setting: no          
  DNSOverTLS setting: no          
      DNSSEC setting: no          
    DNSSEC supported: no          
  Current DNS Server: 192.168.1.70
         DNS Servers: 10.0.2.3    
                      192.168.1.70
                      192.168.1.1 
          DNS Domain: ~. 

So the current DNS Server: 192.168.1.70 as wanted. But this is not always the case. I want to make my system more stable it will always use 192.168.1.70

When cat /run/systemd/resolve/resolv.conf I can see 10.0.2.3 is really defined. I can not (and should not) edit this file but edit /etc/resolv.conf instead.

Viewing cat /etc/resolv.conf does not show DNS server 10.0.2.3 but is does show nameserver 127.0.0.53 And, it again I should not edit this file.

This is weird. First, from a generated file, I get pointed to a file which is used to generated that file and which I should edit instead. And second in that file is a different DNS nameserver mentioned so it seems run/systemd/resolve/resolv.conf is generated from somewhere else.

According to https://askubuntu.com/tags/resolvconf/info is the program to edit resolv.conf. So I tried to use that.

bernard@VBoxMain20:/etc$ resolvconf

Command 'resolvconf' not found, but can be installed with:

sudo apt install openresolv  # version 3.10.0-1, or
sudo apt install resolvconf  # version 1.82

bernard@VBoxMain20:/etc$ sudo apt install openresolv 

So I executed resolvconf but found no way to edit resolv.conf

I also tried to use netplan available from Ubuntu 18.04+ but without success.

I simply want to use the DNS nameservers I defined myself in the GUI and nothing else. How can I do that?

7
  • Isn't 10.0.2.3 coming from your DHCP? You get DNS addresses from DHCP and then your 192.* are added to the list
    – marosg
    Jan 21 at 11:00
  • Possible. In the GUI I wanted to disable DHCP, but I could not. For two days it has the same value. I do not know how fast the IP addresses do change with DHCP.
    – Bernard
    Jan 21 at 11:03
  • In other words, you probably need to use manual option in that dialog. I use Ubuntu Mate and there are two options for that - "Automatic (DHCP)" and "Automatic (DHCP) address only". I use the second one and only DNS I specify there is used.
    – marosg
    Jan 21 at 11:05
  • As you can see in the screenshot I unfortunately I do not have that option.
    – Bernard
    Jan 21 at 11:07
  • I use this if I need to specify DNS. Of course it will be overwritten when you connect next time sudo systemd-resolve --set-dns=10.88.17.67 -i enp0s31f6
    – marosg
    Jan 21 at 11:11
1

Silly question: is this VirtualBox instance using a NAT network? If so, you have two options:

  1. Switch to a "Bridged Network", which will result in the VM having full control over its network resources
  2. Use the host's resolver as a DNS Proxy. As per the documentation:

For resolving network names, the DHCP server of the NAT engine offers a list of registered DNS servers of the host. If for some reason you need to hide this DNS server list and use the host's resolver settings, thereby forcing the VirtualBox NAT engine to intercept DNS requests and forward them to host's resolver, use the following command:

VBoxManage modifyvm "VM name" --natdnshostresolver1 on

Note that this setting is similar to the DNS proxy mode, however whereas the proxy mode just forwards DNS requests to the appropriate servers, the resolver mode will interpret the DNS requests and use the host's DNS API to query the information and return it to the guest.

I generally run all my VBox instances in bridges mode as it avoids these sorts of issues.

Hope this gives you what you need 👍🏻

1
  • I used your suggestion 1, using "Bridged Network". I really like simple, to the point solution, you gave me. Thanks you very much.
    – Bernard
    Jan 21 at 11:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.