If you are first time install WSL2 and reboot or something like it, it may become no internet connectivity and show error
Temporary failure in name resolution
To fix it, please follow this gitgub issue, JohnnyQuest1983's reply.
The steps can be simple like this
- set generateResolvConf=false in /etc/wsl.conf
- set dns in /etc/resolv.conf
then use exit or wsl --shutdown, reboot wsl, and it worked, the internet back.