wlan0 connected to router but no internet

Hi everyone,
Fairly new to linux so please be patient.
I am unable to connect to my RPI on my wireless interface. My PI is connected to the router as I can see it in the list of attached devices. Using the cable I can ssh into my PI.
When I try to ping google from wlan0 it doesn’t work. When I ping it from eth0 it works fine:

dietpi@PI2:~ $ ping -I wlan0 www.google.com
PING www.google.com (216.58.200.100) from 192.168.0.6 wlan0: 56(84) bytes of data.
^C
--- www.google.com ping statistics ---
9 packets transmitted, 0 received, 100% packet loss, time 8281ms

dietpi@PI2:~ $ ping -I eth0 www.google.com
PING www.google.com (172.217.25.164) from 192.168.0.110 eth0: 56(84) bytes of data.
64 bytes from syd09s13-in-f4.1e100.net (172.217.25.164): icmp_seq=1 ttl=54 time=63.0 ms
64 bytes from syd09s13-in-f4.1e100.net (172.217.25.164): icmp_seq=2 ttl=54 time=63.1 ms
^C
--- www.google.com ping statistics ---
3 packets transmitted, 2 received, 33% packet loss, time 2002ms
rtt min/avg/max/mdev = 63.092/63.102/63.113/0.251 ms

This is what ifconfig displays:

dietpi@PI2:~ $ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.110  netmask 255.255.255.0  broadcast 192.168.0.255
        ether zz:zz:zz:zz:zz  txqueuelen 1000  (Ethernet)
        RX packets 6669  bytes 497599 (485.9 KiB)
        RX errors 0  dropped 3  overruns 0  frame 0
        TX packets 9755  bytes 1210317 (1.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 2564  bytes 239309 (233.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 2564  bytes 239309 (233.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.6  netmask 255.255.255.0  broadcast 192.168.0.255
        ether zz:zz:zz:zz:zz  txqueuelen 1000  (Ethernet)
        RX packets 1170  bytes 129432 (126.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 716  bytes 80292 (78.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Found an article online where they were saying to change the /etc/network/interfaces to:

#/etc/network/interfaces
#Please use DietPi-Config to modify network settings.

# Local
auto lo
iface lo inet loopback

# Ethernet
allow-hotplug eth0
iface eth0 inet static
address
netmask
gateway
dns-nameservers 8.8.8.8 8.8.4.4

# Wifi
allow-hotplug wlan0
iface wlan0 inet dhcp
wireless-power off
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
#dns-nameservers 8.8.8.8

And that’s about where I decided I don’t know what to do next.
Any ideas on what I am doing wrong?

Cheers

reduce the # in front of dns-nameservers (otherwise it will not know how to change a url to an ip address)

also make sure that you have stuff in /etc/wpa_supplicant/wpa_supplicant.conf

This is how my wpa_supplicant looks like:

dietpi@PI2:~ $ sudo !!
sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
country=AU
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
    ssid="zzz"
    scan_ssid=1
    key_mgmt=WPA-PSK
    psk="zzz"
}

I also just changed the /etc/network/interfaces to:

dietpi@PI2:~ $ cat /etc/network/interfaces
#/etc/network/interfaces
#Please use DietPi-Config to modify network settings.

# Local
auto lo
iface lo inet loopback

# Ethernet
allow-hotplug eth0
iface eth0 inet static
address
netmask
gateway
dns-nameservers 8.8.8.8 8.8.4.4

# Wifi
allow-hotplug wlan0
iface wlan0 inet dhcp
wireless-power off
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
dns-nameservers 8.8.8.8

I still get

dietpi@PI2:~ $ ping -I wlan0 www.google.com
PING www.google.com (216.58.203.100) from 192.168.0.6 wlan0: 56(84) bytes of data.

--- www.google.com ping statistics ---
6 packets transmitted, 0 received, 100% packet loss, time 5146ms