Score:1

Ubuntu 20.04 Server remove local gateway from DNS Server

ky flag

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
jtessier72 avatar
cn flag
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
Armado avatar
ky flag
I try adding : dhcp4-overrides: use-dns: false , nothing change
jtessier72 avatar
cn flag
Worth asking, but did you do sudo netplan apply and then re-check?
Armado avatar
ky flag
Of course I'm using "sudo" :)
jtessier72 avatar
cn flag
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 ?
Armado avatar
ky flag
@jtessier72 I add resolv.conf and resolved.conf on the main question
jtessier72 avatar
cn flag
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.
Score:1
uz flag

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
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.