1

I'm trying to expand my Google Cloud Platform startup-script so that it sets DNS entries. But every time I include these two lines of code the script does not get executed and fails.

echo "nameserver 0.0.0.0" >> /etc/resolv.conf
echo "nameserver 0.0.0.1" >> /etc/resolv.conf

When I login to the Virtual Machine the commands work fine.

The Error message I get is the following:

Screenshot of Error Message from serial console

Patrick Mevzek
  • 10,995
  • 16
  • 38
  • 54
Michi
  • 29
  • 6
  • Have you tried using sudo to see if that helps in case there is a permission issue? See this thread which discusses a similar issue: https://stackoverflow.com/questions/43900350/compute-engine-startup-script-cant-execute-as-a-non-root-user – Parth Mehta Jan 30 '20 at 08:57
  • My script works fine if i don't include these two lines of code. Its mostly installing packages and the "realm join" command works fine too. I just tried Sudo and nothing changes. But thanks for the advice :) – Michi Jan 30 '20 at 10:57

2 Answers2

1

Please include error messages as text, not as a screenshot.

U+00A0 is a non-breaking space, which looks like an ordinary space, but is not. You need to check the input to make sure that there is a real ASCII space character there (U+0020), and not some other Unicode character.

Florian Weimer
  • 32,022
  • 3
  • 48
  • 92
  • Thank you for you advice. I just typed the commands manually and not with copy & paste and now it works. Thank you soooooo much. – Michi Feb 03 '20 at 10:25
0

By default the path only have write permission for root as following:

-rw-r--r--. 1 root root 146 Jan 30 14:44 /etc/resolv.conf

to allow it to do changes to the file with the startup script, you need to set permissions for write to groups, e.g.

-rw-rw-r--. 1 root root 146 Jan 30 14:44 /etc/resolv.conf