【发布时间】:2021-03-20 03:01:00
【问题描述】:
2 年前,Google 引入了私有 DNS,这对于内部域通信非常重要。
我使用以下文档指南设置了一个私有 dns 来了解 DNS https://cloud.google.com/sdk/gcloud/reference/dns/managed-zones/create https://www.jhanley.com/google-cloud-private-dns-zones/
以下是创建示例区域所遵循的步骤
创建了一个私有区域“private-zone”
gcloud dns managed-zones create --dns-name="example.com" --description="Private Zone" --visibility=private --networks=default "private-zone"
然后在谷歌云中创建一个虚拟机并运行nslookup作为域名。
但是没有解决
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
我在创建的 Vm 实例上使用 Debian OS
Linux testdns 4.19.0-12-cloud-amd64 #1 SMP Debian 4.19.152-1 (2020-10-18) x86_64 GNU/Linux
这是除了NS和SOA记录之外的两条A记录
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
下面的例子已经过测试
nslookup when "example.com" A record is not added
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
#dig example.com 使用 nameserver ,添加了“A”记录
testdns:~$ dig example.com @ns-gcp-private.googledomains.com
; <<>> DiG 9.11.5-P4-5.1+deb10u2-Debian <<>> example.com @ns-gcp-private.googledomains.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- 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
添加example.com后再次nslookup
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
挖掘
testdns:~$ dig example.com
; <<>> DiG 9.11.5-P4-5.1+deb10u2-Debian <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- 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
使用本地主机挖掘
dig example.com @127.0.0.1
; <<>> DiG 9.11.5-P4-5.1+deb10u2-Debian <<>> example.com @127.0.0.1
;; global options: +cmd
;; connection timed out; no servers could be reached
我错过了一些步骤吗?
【问题讨论】:
-
您是否修改了
/etc/resolv.conf或对运行此命令的实例进行了任何其他 DNS 或 DHCP 更改?您希望example.com解决什么问题?除非您已创建 DNS 资源记录,否则 example.com 不会返回任何内容。 -
@JohnHanley;感谢您的回复,我没有修改 resolv.conf 文件我确实希望这会给我一个我在 A 记录中作为私有域设置的一部分而获得的 IP
-
使用 A 记录的详细信息编辑您的问题。您实际上是在使用 example.com 还是只是一个占位符?哪个操作系统和版本?发布此命令的输出
nslookup example.com 127.0.0.1 -
转到 Google Cloud Console -> 网络服务 -> 区域详细信息。查找 NS 资源记录的值。在此命令中将 NS_VALUE 替换为该值:
nslookup example.com NS_VALUE。在您的问题中发布该输出。 -
这就是现在使用 DNS 或 Web 浏览器的工作方式。当您在 Web 浏览器中键入
example.com时,浏览器会显示www.example.com,这是因为 Web 服务器、负载平衡器等进行了 HTTP 重定向。如果您解析example.com,它只会解析example.com。我忽略了通配符。
标签: google-cloud-platform dns nslookup google-cloud-dns