Ubuntu 22.04
Original:
root@ubuntu:~# resolvectl
Global
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Link 2 (ens5)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 12.34.56.78
DNS Servers: 12.34.56.78 12.34.56.79
What I did:
- Add
nameservers
entry in/etc/netplan/01-netcfg.yaml
file
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
version: 2
renderer: networkd
ethernets:
ens5:
dhcp4: yes
nameservers:
addresses: [8.8.8.8, 1.1.1.1]
netplan apply
- Add DNS servers in
/etc/systemd/resolved.conf
file
[Resolve]
DNS=8.8.8.8 1.1.1.1
FallbackDNS=8.8.4.4
systemctl restart systemd-resolved
systemctl enable systemd-resolved
After rebooting:
root@ubuntu:~# resolvectl
Global
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
Current DNS Server: 8.8.8.8
DNS Servers: 8.8.8.8 1.1.1.1
Fallback DNS Servers: 8.8.4.4
Link 2 (ens5)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 8.8.8.8
DNS Servers: 8.8.8.8 1.1.1.1 12.34.56.78 12.34.56.79
How to remove 12.34.56.78
and 12.34.56.79
in DNS server list?
dhcp4-overrides
with a settinguse-dns: false
to ignore the dns servers being pushed down via dhcp if you want.