El shell de linux: Consultar cuáles son los DNS configurados en Ubuntu 22.04 desde el terminal

En Ubuntu 22.04, los DNS se configuran por defecto con systemd.

Si usáis NetWork Manager para gestionar la red, podéis consultar los DNS recibidos vía DHCP utilizando el comando nmcli:

nmcli dev show | grep DNS
IP4.DNS[1]:                             212.230.135.1
IP4.DNS[2]:                             212.230.135.2

Ahora bien, si queréis consultar qué DNS tiene configurados nuestro sistema, tan sólo tenemos que usar el comando resolvectl:

resolvectl status
Global
           Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
    resolv.conf mode: stub
  Current DNS Server: 1.1.1.1
         DNS Servers: 1.1.1.1
Fallback DNS Servers: 8.8.8.8

Link 2 (enp7s0)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 212.230.135.1
       DNS Servers: 212.230.135.1 212.230.135.2
        DNS Domain: Home

En la salida anterior podéis observar que tenemos configurados varios servidores DNS. Los dos primeros (1.1.1.1 y 8.8.8.8) se encuentran configurados en el fichero /etc/systemd/resolved.conf:

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it under the
#  terms of the GNU Lesser General Public License as published by the Free
#  Software Foundation; either version 2.1 of the License, or (at your option)
#  any later version.
#
# Entries in this file show the compile time defaults. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the resolved.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# Use 'systemd-analyze cat-config systemd/resolved.conf' to display the full config.
#
# See resolved.conf(5) for details.

[Resolve]
# Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
# Cloudflare: 1.1.1.1#cloudflare-dns.com 1.0.0.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 2606:4700:4700::1001#cloudflare-dns.com
# Google:     8.8.8.8#dns.google 8.8.4.4#dns.google 2001:4860:4860::8888#dns.google 2001:4860:4860::8844#dns.google
# Quad9:      9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
DNS=1.1.1.1
FallbackDNS=8.8.8.8
#Domains=
#DNSSEC=no
#DNSOverTLS=no
#MulticastDNS=no
#LLMNR=no
#Cache=no-negative
#CacheFromLocalhost=no
#DNSStubListener=yes
#DNSStubListenerExtra=
#ReadEtcHosts=yes
#ResolveUnicastSingleLabel=no

En cuanto al os dos siguientes (212.230.135.1 y 212.230.135.2) son los recibidos vía DHCP.