Why GCP overrides my /etc/resolv.conf file and how to avoid it?

Following Håkan Lindqvist comment I used symbolic link from paragraph 29.2

https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/configuring_and_managing_networking/manually-configuring-the-etc-resolv-conf-file_configuring-and-managing-networking

NetworkManager does not automatically update the DNS configuration if /etc/resolv.conf is a symbolic link. This section describes how to replace /etc/resolv.conf with a symbolic link to an alternative file with the DNS configuration.

  1. Create a file, such as /etc/resolv.conf.manually-configured, and add the DNS configuration for your environment to it. Use the same parameters and syntax as in the original /etc/resolv.conf.

  2. Remove the /etc/resolv.conf file:

    # rm /etc/resolv.conf
    
  3. Create a symbolic link named /etc/resolv.conf that refers to /etc/resolv.conf.manually-configured:

    # ln -s /etc/resolv.conf.manually-configured /etc/resolv.conf
    

The resolv.conf options are renewed every 24 hours for global DNS, as per this official documentation. It is also possible to modify the values, by editing the DHCP Policy.

For Debian 10, Here are the steps:

  1. Edit "/etc/dhcp/dhclient.conf"

  2. Uncomment the line "supersede domain name", and modify the values of it: supersede domain-name "asdf.v1.com";

    NOTE: supersede will use only your provided details, prepend will use first your values then the server-provided ones, and append will use first the server-provided values, and then your custom ones.

  3. Save the file

  4. Restart the DHCP client with the command "sudo dhclient -v -r"

Please keep in mind that these steps might not work for other distributions, make sure to backup and review the steps before performing them.