title: Setting up Private DNS in google cloud
body: <p>2 years back Google introudced private DNS which is very important for internal domains communication.</p>
  <p>I setup a private dns to learn about DNS using below documentation guide
  <a href="https://cloud.google.com/sdk/gcloud/reference/dns/managed-zones/create" rel="nofollow noreferrer">https://cloud.google.com/sdk/gcloud/reference/dns/managed-zones/create</a>
  <a href="https://www.jhanley.com/google-cloud-private-dns-zones/" rel="nofollow noreferrer">https://www.jhanley.com/google-cloud-private-dns-zones/</a></p>
  <p>Below are the steps followed to create an example zone</p>
  <p>Created a private zone &quot;private-zone&quot;</p>
  <pre><code>gcloud dns managed-zones create --dns-name=&quot;example.com&quot; --description=&quot;Private Zone&quot; --visibility=private --networks=default &quot;private-zone&quot;
  </code></pre>
  <p>Then created a vm in google cloud and ran the <code>nslookup</code> for the domain name.
  But it did not resolve</p>
  <pre><code>testdns:~$ nslookup example.com
  Server:         169.254.169.254
  Address:        169.254.169.254#53
  Non-authoritative answer:
  *** Can't find example.com: No answer
  </code></pre>
  <p>I'm using Debian OS on the Vm instance created</p>
  <pre><code>Linux testdns 4.19.0-12-cloud-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux
  </code></pre>
  <p>These are two A records other than NS and SOA records in</p>
  <pre><code>test.example.com.   A   300  192.0.0.9
  www.example.com.    A   300  192.0.0.91
  example.com.        A   3600 192.0.1.1
  </code></pre>
  <p>Below example was tested</p>
  <p>nslookup when &quot;example.com&quot; A record was not added</p>
  <pre><code>mymach@testdns:~$ nslookup example.com ns-gcp-private.googledomains.com
  Server:         ns-gcp-private.googledomains.com
  Address:        169.254.169.254#53
  Non-authoritative answer:
  *** Can't find example.com: No answer
  </code></pre>
  <p>#dig example.com using nameserver , 'A' record was added</p>
  <pre><code>testdns:~$ dig example.com @ns-gcp-private.googledomains.com
  ; &lt;&lt;&gt;&gt; DiG 9.11.5-P4-5.1+deb10u2-Debian &lt;&lt;&gt;&gt; example.com @ns-gcp-private.googledomains.com
  ;; global options: +cmd
  ;; Got answer:
  ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 41534
  ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
  ;; OPT PSEUDOSECTION:
  ; EDNS: version: 0, flags:; udp: 512
  ;; QUESTION SECTION:
  ;example.com.                   IN      A
  ;; ANSWER SECTION:
  example.com.            3600    IN      A       192.0.1.1
  ;; Query time: 12 msec
  ;; SERVER: 169.254.169.254#53(169.254.169.254)
  ;; WHEN: Tue Dec 08 23:03:58 UTC 2020
  ;; MSG SIZE  rcvd: 56
  </code></pre>
  <h1>nslookup again after adding example.com</h1>
  <pre><code>testdns:~$ nslookup example.com ns-gcp-private.googledomains.com
  Server:         ns-gcp-private.googledomains.com
  Address:        169.254.169.254#53
  Non-authoritative answer:
  Name:   example.com
  Address: 192.0.1.1
  </code></pre>
  <h1>dig</h1>
  <pre><code>testdns:~$ dig example.com 
  ; &lt;&lt;&gt;&gt; DiG 9.11.5-P4-5.1+deb10u2-Debian &lt;&lt;&gt;&gt; example.com
  ;; global options: +cmd
  ;; Got answer:
  ;; -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 24673
  ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
  ;; OPT PSEUDOSECTION:
  ; EDNS: version: 0, flags:; udp: 512
  ;; QUESTION SECTION:
  ;example.com.                   IN      A
  ;; ANSWER SECTION:
  example.com.            3600    IN      A       192.0.1.1
  ;; Query time: 11 msec
  ;; SERVER: 169.254.169.254#53(169.254.169.254)
  ;; WHEN: Tue Dec 08 23:06:30 UTC 2020
  ;; MSG SIZE  rcvd: 56
  </code></pre>
  <h1>dig using local host</h1>
  <pre><code>dig example.com @127.0.0.1
  ; &lt;&lt;&gt;&gt; DiG 9.11.5-P4-5.1+deb10u2-Debian &lt;&lt;&gt;&gt; example.com @127.0.0.1
  ;; global options: +cmd
  ;; connection timed out; no servers could be reached
  </code></pre>
  <p>Am I missing some step ?</p>