This is a basic thing that it’s normally working Out-of-the-box but that sometimes it doesn´t work. Today is one of that days.

How to detect it?

In my case it was because Ubuntu doesn’t let me to update apt cache:

apt cache can´t be updated

So, how to fix it?

Edit the default DNS

To do that is as easy as run sudo vim /etc/resolv.conf and change the file to:

# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
#nameserver XXX.XXX.XXX.XXX
nameserver 9.9.9.9
~

As an example I’m using the Quad9 DNS but you can choose the one you want.

And as easy as that, you will have the domain resolution working.