NSLookup你该退休了 1


上次我们提到Windows 8.1或者Windows Server 2012 R2中,Ping命令可以领退休金了。今天再来让NSlookup也归隐山林吧。在Windows 4.0 中有一个组件DnsClient,里面有17条命令,来帮助我们查询和设置DNS相关的配置。

查询DnsClient相关命令

使用Get-Command目睹这17条DnsClient命令的芳容:

PS> Get-Command -Module DnsClient | select CommandType, Name
CommandType Name
----------- ----
   Function Add-DnsClientNrptRule
   Function Clear-DnsClientCache
   Function Get-DnsClient
   Function Get-DnsClientCache
   Function Get-DnsClientGlobalSetting
   Function Get-DnsClientNrptGlobal
   Function Get-DnsClientNrptPolicy
   Function Get-DnsClientNrptRule
   Function Get-DnsClientServerAddress
   Function Register-DnsClient
   Function Remove-DnsClientNrptRule
   Function Set-DnsClient
   Function Set-DnsClientGlobalSetting
   Function Set-DnsClientNrptGlobal
   Function Set-DnsClientNrptRule
   Function Set-DnsClientServerAddress
     Cmdlet Resolve-DnsName

解析域名的IP地址

相信绝大多同仁使用NSLookup做的最多的事恐怕就是解析域名的IP地址吧。我们今天就拿Google开刀,为啥要拿它开刀,解析出谷歌的IP地址后,如果此IP地址没被狗啃,就可以直接访问谷歌美国啦(其中type 为AAAA的代表的是IPV6)。

PS> Resolve-DnsName Google.com |ft -AutoSize

Name       Type TTL Section IPAddress
----       ---- --- ------- ---------
Google.com AAAA 260 Answer  2607:f8b0:400a:803::1006
Google.com A    260 Answer  173.194.33.104
Google.com A    260 Answer  173.194.33.103
Google.com A    260 Answer  173.194.33.102
Google.com A    260 Answer  173.194.33.100
Google.com A    260 Answer  173.194.33.99
Google.com A    260 Answer  173.194.33.105
Google.com A    260 Answer  173.194.33.101
Google.com A    260 Answer  173.194.33.98
Google.com A    260 Answer  173.194.33.110
Google.com A    260 Answer  173.194.33.96
Google.com A    260 Answer  173.194.33.97

查看本地的DNS服务器地址

PS> Get-DnsClientServerAddress

InterfaceAlias               Interface Address ServerAddresses
                             Index     Family
--------------               --------- ------- ---------------
Ethernet                             3 IPv4    {192.168.11.20, 8.8.8.8}
Ethernet                             3 IPv6    {}
Loopback Pseudo-Interface 1          1 IPv4    {}
Loopback Pseudo-Interface 1          1 IPv6    {fec0:0:0:ffff::1, fec0:0:0:ffff::2, fec0:0:0:ffff::3}
isatap.wwww.pstips.net               4 IPv4    {}
isatap.wwww.pstips.net               4 IPv6    {}

查看DNS的缓存

我以前只用过IPConfig清除过本地DNS缓存,从来没看多DNS缓存长啥样,今天可以看了。

PS C:\Users\v-bali> Get-DnsClientCache

Entry                     RecordName                Record Status    Section TimeTo Data L Data
                                                    Type                     Live   ength
-----                     ----------                ------ ------    ------- ------ ------ ----
db3-exch-dc-03.exchang... DB3-EXCH-DC-03.exchang... A      Success   Answer    2320      4 1.221.18.9
sin-red-dc-01.mond....    SIN-RED-DC-01.mond....    A      Success   Answer     945      4 1.60.220.23
crl.globalsign.com        crl.globalsign.com        A      Success   Answer     215      4 1.162.232.205
crl.globalsign.com        crl.globalsign.com        A      Success   Answer     215      4 1.162.232.204
crl.globalsign.com        crl.globalsign.com        A      Success   Answer     215      4 1.162.232.201
crl.globalsign.com        crl.globalsign.com        A      Success   Answer     215      4 1.162.232.202
crl.globalsign.com        crl.globalsign.com        A      Success   Answer     215      4 1.162.232.197

清除本地DNS缓存

有的哥们上完网后喜欢把自己的浏览器地址清除掉,可是别忘了DNS缓存里面也有痕迹啊。

Clear-DnsClientCache

查看DNS客户端

PS C:\Users\v-bali> Get-DnsClient

InterfaceAlias               Interface ConnectionSpecificSuffix ConnectionSpecificSuffix RegisterThisConn UseSuffixWhen
                             Index                              SearchList               ectionsAddress   Registering
--------------               --------- ------------------------ ------------------------ ---------------- -------------
Ethernet                             3 www.pstips.net           {}                       True             True
Loopback Pseudo-Interface 1          1                          {}                       True             True
isatap.wwww.pstips.net               4                          {}                       True             True
本文链接: https://www.pstips.net/abandoned-nslookup.html
请尊重原作者和编辑的辛勤劳动,欢迎转载,并注明出处!

关于 Mooser Lee

我是一个Powershell的爱好者,创建了PowerShell中文博客,热衷于Powershell技术的搜集和分享。本站部分内容来源于互联网,不足之处敬请谅解,并欢迎您批评指正。

发表评论

您的电子邮箱地址不会被公开。 必填项已用 * 标注

一条评论 “NSLookup你该退休了