Looks like you are bang on the money. I altered this line and DNS started resolving straight away.
So, are you saying that $gatewayIP should be the IP Address for my internet gateway/router? On line 77 it looks like $gatewayIP is set. I stuck an 'echo $gatewayIP' just before line 142, just to get visibility of what it's being set to, and currently it is being set to 0.0.0.0? I manually set it to my router IP (192.168.0.254) and everything worked as expected. Is $gatewayIP supposed to be 0.0.0.0 or is this a bug in the script or a peculiarity in my setup?
Thanks for your help with this...it's proving to be a great learning exercise. Really appreciate it. :)