擅长:python、mysql、java
<p>这两个IP地址都解析为古戈尔. 我们可以通过unix whois命令从命令行验证这一点。你知道吗</p>
<pre><code>$ whois 216.58.208.36
NetRange: 216.58.192.0 - 216.58.223.255
CIDR: 216.58.192.0/19
NetName: GOOGLE
$ whois 173.194.39.0
NetRange: 173.194.0.0 - 173.194.255.255
CIDR: 173.194.0.0/16
NetName: GOOGLE
</code></pre>
<p>我遇到了同样的问题,原因是需要IP地址的第一个命令使用了缓存的DNS条目(因为DNS条目的生存时间(TTL)尚未过期),然后在发出第二个命令时,缓存条目上的TTL已过期,因此为域发出了新的DNS请求,因此获取了来自DNS服务器的新IP地址恰好不同,因为域有很多IP地址,就像古戈尔. 你知道吗</p>
<p>Python只依赖于操作系统的DNS解析器(或者任何正在运行的守护进程),据我所知,socket模块不能在解析地址之前清除DNS缓存。如果你想更多的控制这个功能,你可以使用DNSPython或类似的东西。如果您在您的操作系统上(例如在Linux上)使用DNS守护程序,那么通常重新启动守护程序将强制刷新DNS缓存,并且您发现这两个地址是相同的(除非您遇到如上所述的TTL过期的定时问题)。你知道吗</p>