Migrate for Compute Engine provides a way to set and control the external DNS settings of migrated VMs. To do this, configure DNS settings in the Google Cloud project using Google Cloud project metadata. These settings are applied to new VMs as they are migrated.
How DNS settings are applied
The DNS settings are applied as follows:
- For Windows clients, the key-value pairs are applied to all NICs as
follows:
dns-domain-name
: Replaces theDNS suffix for this connection
setting per NIC.dns-servers
: Replaces the list of DNS servers per NIC.dns-domain-suffixes
: Replaces the list of DNS suffixes per NIC.
- For Linux clients, the key-value pairs are applied to all NICs as
follows:
dns-servers
: Prepends the list of DNS servers in theresolv.conf
file.dns-domain-suffixes
: Prepends the list of DNS suffixes in theresolv.conf
file.
Configuring your VMs to connect to the metadata server
Google Cloud provides metadata to VMs hosted on Compute Engine. To use external DNS without forwarding to Cloud DNS, you need to configure name resolution for your VMs manually.
To do so, add the following line to the /etc/hosts
file (on Linux)
or c:\Windows\System32\Drivers\etc\hosts
(on Windows).
169.254.169.254 metadata.google.internal
Automating this step is possible with scripted custom adaptations.
Configuring external DNS data on VMs in GCP
To enable external DNS on migrated VMs:
- In the Google Cloud console, go to the Metadata page for your project.
- Under Metadata, click Edit.
- In the Metadata page, add the appropriate key-value pairs. Use
one of the following sections for instructions for these deployments:
- If your VMs don't have a region setting, follow the instructions in Using VMs without a region setting. This configuration only affects VMs in a specific region.
- If your VMs have a region setting, follow the instructions in Using VMs with a region setting to use the default configuration which is a project-wide setting.
Using VMs without a region setting (default)
If your VMs don't have a specific region setting, add the following key-value pairs in the Metadata page:
Key Example Value default_dns-domain-name
: mydomain.com
default_dns-servers
: {comma separated list of IPs}
default_dns-domain-suffixes
mydomain.com, myseconddomain.com
When you're done, click Save.
Using VMs with a region setting
If your VMs have a specific region setting, add the following key-value pairs in the Metadata page:
Description Key Example Value Windows clients {region_name}_dns-domain-name
: mydomain.com
List of DNS servers {region_name}_dns-servers
: {comma separated list of IPs}
List of DNS suffixes to add to Windows and Linux machines {region_name}_dns-domain-suffixes
mydomain.com, myseconddomain.com
When you're done, click Save.