Name resolution error on WSL2 Ubuntu

I get the following error message using WSL2 Ubuntu:

$ ping google.com
ping: google.com: Temporary failure in name resolution

To fix this do the following:

$ sudo nano /etc/resolv.conf

Change or add:

nameserver 8.8.8.8

You probably have to do this each time you start a session. I think there is a fix, but my company has a security policy that I cannot change locally. Maybe, I can run a script during the session opening to update this file.

Brian Johnson @brian3johnson