Unable to get Ubunto's VM internal network behind a NAT to use the host connection

I have setup a NAT network with an internal virtual switch using the below commands:

New-VMSwitch -SwitchName "NAT" -SwitchType Internal
New-NetIPAddress -IPAddress 192.168.8.1 -PrefixLength 24 -InterfaceAlias "vEthernet (NAT)"
New-NetNAT -ame "NATNetwork" -InternalIPInterfaceAddressPrefix 192.168.8.0/24

I configured my Ubuntu VM on Hper-V to use the "NAT" internal network switch on the VM settings of the Hyper-V, however I cannot get an internet connection. my route table on the VM is below:

default via 192.168.8.1 dev eth0 proto static metric 20100
169.254.0.0/16 dev eth0 scope link metric 1000
192.168.8.0/24 dev eth0 proto kernel scope link src 192.168.8.1 metric 100 

Edit: I'm able to ping the VM from the host machine and vice versa


It turns out that the DNS resolving was the issue. Below article steps solved my issue: https://letsfoss.com/temporary-failure-in-name-resolution/