https://askubuntu.com/questions/2219/how-do-i-clear-the-dns-cache
====== Ubuntu 17.04 and higher (18.04) ======
From Ubuntu 17.04 and onwards, systemd-resolve is used for DNS. You can flush systemd's caches like so:
sudo systemd-resolve --flush-caches
====== Ubuntu 22.04 and higher ======
sudo resolvectl flush-caches