-2

Just created a Reverse DNS Managed Zone as mentioned here - https://cloud.google.com/dns/docs/zones/managed-reverse-lookup-zones - How do we add VM IPs ? with Terraform - Since the Reverse DNS Zone adds Networks to it - Wondering How will add PTR records to the Zone?

John Hanley
  • 74,467
  • 6
  • 95
  • 159

1 Answers1

0

You cannot add records to a reverse lookup DNS zone directly; the data comes from the Compute Engine IP address data. Instead, add or modify the Access Configuration for the VM.

Note: You must first verify ownership of the domain. Ownership is verified in Webmaster Central.

To create a DNS PTR record for an existing Compute Engine VM instance, use the command flag --public-ptr.

Examples:

gcloud compute instances add-access-config [INSTANCE_NAME] \
    --public-ptr --public-ptr-domain [DOMAIN_NAME]

Use this command if the VM already has an access configuration:

gcloud compute instances update-access-config [INSTANCE_NAME] \
    --public-ptr --public-ptr-domain [DOMAIN_NAME]

Creating a PTR Record for a VM Instance

John Hanley
  • 74,467
  • 6
  • 95
  • 159
  • So I added a PTR record for a VM and added it to a private DNS zone. Now if I just fetch DNS info using dig -x VM IP. It points to the hostname of the VM that was set using hostnamectl command. And if there is no hostname a reverse PTR lookup point to Cloud DNS internal address. is this expected behaviour? – UngabungaBoy22 Aug 22 '22 at 21:08
  • dig -x 10.154.0.2 ; <<>> DiG 9.16.27-Debian <<>> -x 10.154.0.2 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44009 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 512 ;; QUESTION SECTION: ;2.0.154.10.in-addr.arpa. IN PTR ;; ANSWER SECTION: 2.0.154.10.in-addr.arpa. 300 IN PTR instance0.customhostname. ;; Query time: 8 msec ;; SERVER: 169.254.169.254#53(169.254.169.254) ;; WHEN: Mon Aug 22 21:11:58 UTC 2022 ;; MSG SIZE rcvd: 94 – UngabungaBoy22 Aug 22 '22 at 21:09
  • @UngabungaBoy22 - you are running dig inside the VM so it is querying the metadata server. Use dig from the Internet. – John Hanley Aug 22 '22 at 21:22