4

I've already read the link here. I tried this from the accepted answer nmcli device status but I get this result sudo: nmcli: command not found. Then I read this link. I tried this systemd-resolve --status | grep 'DNS Servers' but I get this result sudo: systemd-resolve: command not found.

Does anyone know a command that will work on 22.04?

CB_Ron
  • 187
  • systemd-resolve is obsolete, and not normally a part of 22.04. The nmcli comand is from package network-manager, is that installed? – ubfan1 Jun 27 '23 at 21:26
  • @ubfan1 no, it is not. Trying it now. – CB_Ron Jun 27 '23 at 21:29
  • @ubfan1 I installed network-manager, now when I run sudo nmcli device status all devices have unmanaged under STATE and no other data. – CB_Ron Jun 27 '23 at 21:32
  • @ubfan1 I have a few fresh instant of Ubuntu 22.04 and 23.04 in VMs. As far as I can see systemd-resolve.service is active and running. It is very much a part of Ubuntu desktop installations. – user68186 Jun 27 '23 at 21:32
  • 1
    resolvectl status works for me. – user68186 Jun 27 '23 at 21:40
  • @user68186 The program systemd-resolve is not the deamon, systemd-resolved, but since the name caused much confusion, I can see why it was removed (replaced by resolvectl). – ubfan1 Jun 28 '23 at 00:16

1 Answers1

7

With Ubuntu Server 22.04, networking is managed with systemd-networkd (not NetworkManager). Configure your network settings with Netplan

DNS name resolution is provided by a service called systemd-resolved. It offers DNS resolution via a D-Bus interface, the resolve NSS service (nss-resolve(8)), and a local DNS stub listener on 127.0.0.53. If you run the command, cat /etc/resolv.conf, you’ll see that it lists 127.0.0.53 as the DNS server. This is the local stub resolver.

$ cat /etc/resolv.conf
# This is /run/systemd/resolve/stub-resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53 options edns0 trust-ad search localdomain

When you run the command, ls -l /etc/resolv.conf, you’ll see that it links to a file the defines the local stub resolver:

$ ls -l /etc/resolv.conf
lrwxrwxrwx 1 root root 37 Mar 20 10:16 /etc/resolv.conf -> /run/systemd/resolve/stub-resolv.conf

This is normal behavior. It caches DNS queries locally to resolve. If a query is not in the cache, then it will query any uplink DNS servers that have been delivered via DHCP or manually defined in your Netplan configuration file. To see what your uplink DNS servers are, run resolvectl status:

$ resolvectl status
Global
       Protocols: -LLMNR -mDNS -DNSOverTLS
                  DNSSEC=no/unsupported
resolv.conf mode: stub

Link 2 (eth0) Current Scopes: none Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

Link 3 (eth1) Current Scopes: none Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

Link 4 (bond0) Current Scopes: DNS Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported Current DNS Server: 192.168.10.1 DNS Servers: 192.168.10.1 DNS Domain: localdomain

user535733
  • 62,253
mpboden
  • 1,389