This section provides optional steps for users who need to bypass the native Google Cloud Platform DNS service and use their own external or self-hosted DNS resolvers instead.
This configuration is often required for software like the Netskope Publisher, which must connect to an organization’s private DNS servers to resolve internal application domains.
About the gce-resolved.conf File
Recent versions of the Google Compute Engine package include a file at /etc/systemd/resolved.conf.d/gce-resolved.conf. GCP added this file to ensure that lookups for internal .local Cloud DNS domains are correctly routed to the GCP metadata server (169.254.169.254).
A side effect of this file is that it can route all DNS traffic to the metadata server, which may conflict with the need to use an external DNS service. If your environment doesn’t rely on GCP’s .local domain resolution, you can safely remove this file to resolve the conflict.
The following steps explain how to do this.
Configuration Steps
You’ll need sudo or root privileges to perform these commands.
Remove the GCP DNS Configuration File
To disable the override, you must remove the auto-generated configuration file.
sudo rm /etc/systemd/resolved.conf.d/gce-resolved.conf
Set your Custom DNS Servers
Add the netplan config to specify your DNS servers.
- Open the file with a text editor like nano:
sudo vi /etc/netplan/80-custom-dns.yaml
- The following is an example of using
8.8.8.8and1.1.1.1as your DNS server, and usingdomain.comas the search domain:network: version: 2 renderer: networkd ethernets: ens4: dhcp4: true dhcp4-overrides: use-dns: false dhcp6: true dhcp6-overrides: use-dns: false nameservers: addresses: - 8.8.8.8 - 1.1.1.1 search: - domain.com - Save the file and exit the editor.
- Set appropriate file permissions.
sudo chmod 600 /etc/netplan/80-custom-dns.yaml
- Test the changes:
sudo netplan try
- Apply the changes.
sudo netplan apply
Restart the Resolver Service
sudo systemctl restart systemd-resolved
Validation
Run resolvectl status again. Confirm that the DNS Servers line now shows your custom server IPs and that $169.254.169.254$ is no longer listed.
Your should be able to see your custom DNS servers and search domain in /etc/resolv.conf .
(Optional) Fix Hostname Resolution Issues
If you see an error like Unable to resolve host ubuntu-22: Name or service not known, add your hostname entry to /etc/hosts.
127.0.0.1 ubuntu-22

