google-cloud-platform: External DNS configuration is not working

1.3k Views Asked by At

Basic Info:

    Region: us-west1
    Zone: us-west1-a
    DNS internal IP address: 10.36.2.15 (Windows Server2016, created from marketplace image)
    VCP name: Default

I have followed below link to configured external DNS in google-cloud-platform.

https://cloud.google.com/migrate/compute-engine/docs/4.2/how-to/networking/using-external-dns

But I think google-cloud-platform doesn't use meata data keys given and its Velostrata that uses these keys to configured DNS.

Another approach is add external DNS configuration under "Cloud DNS"-> "DNS Server Policies".

Steps which followed to configured external DNS in google-cloud-platform:

  1. Created Windows2016 server in zone 'us-west1-a' with internal(10.36.2.15) and external IPs and configured DNS
  2. In "Compute Engine"-> "Settings" -> "metadata" added following key-value pairs as described in above link:
     us-west1_dns-domain-name: abc.com 
     us-west1_dns-domain-suffixes: abc.com
     us-west1_dns-servers: 10.36.2.15
  1. Go to "Network Service" -> "Cloud DNS" -> "DNS Server Policies" -> "Create Policy" and added following:
    Name: gcp-dns-server1
    Inbound query forwarding : off
    Alternate DNS servers (Optional)" : 10.36.2.15
    Networks: Default
  1. Go to "VPC Networks" -> "VPC Networks" -> select "default" VPC Checked "DNS server policy": "gcp-dns-server1" is applied

  2. Now when I created a new Virtual Machine in "Default" subnet and checked "/etc/resolv.conf" then machine is configured with internal DNS

     #$ cat /etc/resolv.conf 
        # Generated by NetworkManager
        search c.my-project.internal google.internal
        nameserver 169.254.169.254
    
     #$ cat /etc/hosts
           127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
           ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
           10.36.2.23  test4.c.my-project.internal test4  # Added by Google
           169.254.169.254 metadata.google.internal  # Added by Google
    

    VM came up on network successfully and able to ping DNS.

  3. I was expecting new Virtual Machine's DNS in "/etc/resolv.conf" is "10.36.2.15" which VM should pick automatically but it didn't work.

Note: When I gave DNS "10.36.2.15" manually in "/etc/resolv.conf" then its working fine with expected name resolution. Which means there are no port issue and VM can communicate successfully with DNS.

What I need is VM should take external DNS automatically at boot up time and entry should reflect in "/etc/resolv.conf" in google-cloud-platform's VM. dhclient file also have internal DNS entry.

Is there any way to tell google-cloud-platform to use external configured DNS(or override internal DNS entries) and update "/etc/resolv.conf" on VM(either on boot up or when dhclient service refreshed) automatically with external DNS?

1

There are 1 best solutions below

0
On

As the Documentation states "..To use external DNS without forwarding to Cloud DNS, you need to configure name resolution for your VMs manually.".

After reviewing your steps I've noticed that maybe you forgot to add the following line to the c:\Windows\System32\Drivers\etc\hosts.

169.254.169.254 metadata.google.internal

Please check that setting on the official documentation [1].

Pablo.

[1] https://cloud.google.com/migrate/compute-engine/docs/4.2/how-to/networking/using-external-dns#configuring_your_vms_to_connect_to_the_metadata_server