简体   繁体   English

为支持CNAME记录的A记录配置的TTL

[英]Configured TTL for A record(s) backing CNAME records

I'm using libresolv to fetch a list of authoritative nameservers for a domain and then query one of those nameservers directly to resolve a host. 我正在使用libresolv来获取域的权威名称服务器列表,然后直接查询这些名称服务器之一来解析主机。

That way, I can get the configured TTL for the A record and then I choose to refresh my DNS records in my code at that TTL. 这样,我可以获取A记录的已配置TTL,然后选择在该TTL的代码中刷新DNS记录。

However, I've run into a snafu in that i'm not sure how to handle hosts that refer to CNAMES. 但是,我遇到了麻烦,因为我不确定如何处理引用CNAMES的主机。 For example, output from www.microsoft.com looks like this: 例如, www.microsoft.com输出看起来像这样:

; <<>> DiG 9.7.3 <<>> www.microsoft.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3870
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 8, ADDITIONAL: 7

;; QUESTION SECTION:
;www.microsoft.com.             IN      A

;; ANSWER SECTION:
www.microsoft.com.      5       IN      CNAME   toggle.www.ms.akadns.net.
toggle.www.ms.akadns.net. 5     IN      CNAME   www.microsoft.com-c.edgekey.net.
www.microsoft.com-c.edgekey.net. 5 IN   CNAME   www.microsoft.com-c.edgekey.net.globalredir.akadns.net.
www.microsoft.com-c.edgekey.net.globalredir.akadns.net. 5 IN CNAME e10088.dspb.akamaiedge.net.
e10088.dspb.akamaiedge.net. 5   IN      A       23.194.222.159

Should I be refreshing my host using the CNAME TTL? 我应该使用CNAME TTL刷新主机吗? If so, how do I get that configured TTL for the CNAME? 如果是这样,我如何获得为CNAME配置的TTL?

Or, should I be refreshing my using using the A record which is linked to the CNAMEs (ie e10088.dspb.akamaiedge.net )? 或者,是否应该使用链接到CNAME的A记录(即e10088.dspb.akamaiedge.net )来刷新我的使用记录? If so, how do I fetch the configured TTL for that host? 如果是这样,我如何获取该主机的已配置TTL?

Any information you experts can provide would be greatly appreciated. 您的专家可以提供的任何信息将不胜感激。

In the case of CNAME's for load balanced servers, you'd want to refresh at the closest record to you, which is the initial lookup. 对于用于负载平衡服务器的CNAME,您希望刷新到最接近的记录,这是初始查找。 Consider the rest of the lookups as backend processing, which in this case, I like to call the Akamai shuffle. 将其余查找视为后端处理,在这种情况下,我喜欢将其称为Akamai随机播放。

EDIT: If you query the authoritative NS directly, you should get the "real" TTL: 编辑:如果您直接查询权威的NS,您应该得到“真实”的TTL:

rickbuford@ent01:~$ dig +noall +answer @ns2.google.com www.google.com
www.google.com.         300     IN      A       74.125.194.103
www.google.com.         300     IN      A       74.125.194.147
www.google.com.         300     IN      A       74.125.194.99
www.google.com.         300     IN      A       74.125.194.105
www.google.com.         300     IN      A       74.125.194.106
www.google.com.         300     IN      A       74.125.194.104

The TTL countdown is a function of a caching LDNS or intermediary server. TTL倒计时是缓存LDNS或中间服务器的功能。 So, in your example: 因此,在您的示例中:

First, do your primary lookup: 首先,进行主要查找:

rickbuford@ent01:~$ dig www.microsoft.com

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> www.microsoft.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 54032
;; flags: qr rd ra; QUERY: 1, ANSWER: 5, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;www.microsoft.com.             IN      A

;; ANSWER SECTION:
www.microsoft.com.      60      IN      CNAME   toggle.www.ms.akadns.net.
toggle.www.ms.akadns.net. 123   IN      CNAME   www.microsoft.com-c.edgekey.net.
www.microsoft.com-c.edgekey.net. 10967 IN CNAME www.microsoft.com-c.edgekey.net.globalredir.akadns.net.
www.microsoft.com-c.edgekey.net.globalredir.akadns.net. 576 IN CNAME e10088.dspb.akamaiedge.net.
e10088.dspb.akamaiedge.net. 17  IN      A       172.233.22.36

;; Query time: 19 msec
;; SERVER: 192.168.186.1#53(192.168.186.1)
;; WHEN: Thu Jun 11 21:24:28 CDT 2015
;; MSG SIZE  rcvd: 237

Then you need to get the NS/SOA of the last CNAME: 然后,您需要获取最后一个CNAME的NS / SOA:

rickbuford@ent01:~$ dig e10088.dspb.akamaiedge.net NS

; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> e10088.dspb.akamaiedge.net NS
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 17178
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4000
;; QUESTION SECTION:
;e10088.dspb.akamaiedge.net.    IN      NS

;; AUTHORITY SECTION:
dspb.akamaiedge.net.    965     IN      SOA     n0dspb.akamaiedge.net. hostmaster.akamai.com. 1434075886 1000 1000 1000 1800

;; Query time: 15 msec
;; SERVER: 192.168.186.1#53(192.168.186.1)
;; WHEN: Thu Jun 11 21:25:01 CDT 2015
;; MSG SIZE  rcvd: 119

You should then be able to query the authoritative server for the record: 然后,您应该能够查询权威服务器的记录:

rickbuford@ent01:~$ dig +noall +answer @n0dspb.akamaiedge.net e10088.dspb.akamaiedge.net
e10088.dspb.akamaiedge.net. 20  IN      A       23.207.250.131

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM