How to stop & disable stub DNS resolver

If you're having issues with a stub DNS resolver, we explain how to deal with this issue on Linux Ubuntu systems

If you're running Ubuntu Linux 20.04 (probably older versions as well), you may have noticed that your DNS server is set to I believe that this is called a local stub DNS.
The issue is that sometimes, when running local services, your stub DNS resolver will actually be the first one to respond, not your actual DNS server (internal or external).
I'm not a sysadmin, but I've found a way to resolve (no pun intended) the issue for me:

systemctl stop systemd-resolved
systemctl disable systemd-resolved

Now you can edit /etc/resolv.conf and add your own nameservers into it. If the file is unwritable or it doesn't exist, you should be able to add it yourself.
See for yourself:

# service systemd-resolved disable
# service systemd-resolved stop
# ping
ping: Temporary failure in name resolution
# nano /etc/resolv.conf

Added the nameserver at the bottom of the file:

# This file is managed by man:systemd-resolved(8). Do not edit.
# 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 must 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  # my local DNS server

Retried the ping:

# ping   
PING ( 56(84) bytes of data.
64 bytes from ( icmp_seq=1 ttl=116 time=1.11 ms
64 bytes from ( icmp_seq=2 ttl=116 time=1.26 ms