nslookup 查询 DNS
date
slug
nslookup
status
Published
summary
tags
网络
type
Post
事情的起因是:在现场客户环境里,同事A与同事B浏览了同一个网站,但是获取的html文件各不相同,其中同事A没有取到最新部属的html文件而是获取到的是之前发布的html文件。在排除了没有html缓存情况下,想到了DNS,会不会两个同事各自的电脑访问到了不同的服务器上。于是乎,自己使用了 `nslookup` 命令来查询网站域名对应的服务器IP地址,可是返回了相同的,这就更百思不得其解了。
后来同事告诉我其中一个有问题的同事是因为没有配置hosts文件,所以才出现了该问题。可是我nslookup得到的ip地址不是一样的么,难道nslookup不会取hosts文件里的配置么。
于是,我问了chatGPT相应的问题:

嗯?会返回hosts文件里的配置吗?带着疑问,我本地试了下,发现实际根本就不会返回hosts文件里的配置。
继续用wireshake抓包试了一下。

结果果然再次证明chatGPT在胡诌八道。
搜索了一番,在stackoverflow上找到了一个答案:
On Windows, if you are looking upserver1you can compare the IP address printed in the output ofping server1with the output of thenslookup server1command.This URL states that on Windows,nslookupdoes not use thehostsfile:Bothping server1andnslookup server1print the IP address they associate withserver1, butpingwill use thehostsfile (on my system) andnslookupdoes not.