Ubuntu set a temporary dns nameserver

Example for Google Nameserver:

  • echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf

Reset local DNS cache

  • systemd-resolve --flush-caches

or for older Ubuntu versions:

  • /etc/init.d/networking restart