1

Here is my setup :

 network:
 version: 2
 renderer: NetworkManager
 #renderer: networkd
 ethernets:
  enp2s0:
   dhcp4: yes
   addresses: []
   nameservers:
           addresses: [1.1.1.1, 1.0.0.1]
  enx28ee52061e61:
   dhcp4: yes
   addresses: []

systemd-resolve --status | grep 'DNS Servers' -A2

DNS Servers: 192.168.1.1
                  1.1.1.1
                  1.0.0.1

So every domain is resolved from 192.168.1.1 (router-gateway IP).

How can i remove it and all domains resolved from "1.1.1.1"?

cat /etc/resolv.conf

nameserver 192.168.1.1
nameserver 1.1.1.1
nameserver 1.0.0.1
# Too many DNS servers configured, the following entries may be ignored.
nameserver fe80::1%2
search home

cat /etc/systemd/resolved.conf

[Resolve]
#DNS=
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=no-negative
#DNSStubListener=yes
#ReadEtcHosts=yes
Armado
  • 11
  • 2
  • Looks like your DHCP server is specifying that DNS, so it is getting used as well as the netplan ones. Does this help? https://askubuntu.com/questions/1001241/can-netplan-configured-nameservers-supersede-not-merge-with-the-dhcp-nameserve – jtessier72 Sep 01 '21 at 20:19
  • I try adding : dhcp4-overrides: use-dns: false , nothing change – Armado Sep 01 '21 at 21:35
  • Worth asking, but did you do sudo netplan apply and then re-check? – jtessier72 Sep 02 '21 at 13:02
  • Of course I'm using "sudo" :) – Armado Sep 03 '21 at 19:41
  • I ran a test on ubuntu server 20.04. My dns was from DHCP at first. Adding nameservers option made it 2 dns servers from netplan and 1 from DHCP. Adding the override made it netplan only. What is your /etc/resolv.conf and /etc/systemd/resolved.conf ? – jtessier72 Sep 03 '21 at 20:45
  • @jtessier72 I add resolv.conf and resolved.conf on the main question – Armado Sep 04 '21 at 18:32
  • Try this... change 1.0.0.1 to 2.2.2.2 in netplan and use 'sudo netplan apply'. And check the dns servers. Or just set "DNS=1.1.1.1" in /etc/systemdresolved.conf. Seems like netplan is not applied or 192.168.1.1 is coming from somewhere. – jtessier72 Sep 04 '21 at 19:50

1 Answers1

1

This has been answered here https://askubuntu.com/a/1084736/993552

Basically in your /etc/netplan/filename.yaml add

dhcp4-overrides:
  use-dns: no

sudo netplan apply #do this after changing config

This will ensure whatever DNS nameservers come from DHCP will not be used by your link (ethernet or whatever network connection you change settings in)

Example

network:
  ethernets:
    ens5:
        dhcp4: true
        dhcp4-overrides:
            use-dns: no
        dhcp6: false
        set-name: ens5
        nameservers:
            addresses: [8.8.8.8, 4.4.4.4]
version: 2