Ant*_*yko 205 dns command-line nslookup
我想向我知道其 IP 地址的特定 DNS 服务器发出查询。它是在 Windows 上还是在 *nix 上并不重要。
在 Windows 中,我可以执行以下操作:
C:\Documents and Settings\Anton Daneyko>nslookup superuser.com
Server: DNSs2.Uni-Marburg.DE
Address: 137.248.21.22
Non-authoritative answer:
Name: superuser.com
Address: 64.34.119.12
Run Code Online (Sandbox Code Playgroud)
但这使用本地机器的 DNS 设置。相反,我想查询特定的 DNS 服务器以测试它是否正确响应我的查询或根本响应。
所以它应该是这样的:
nslookup --dns-ip=8.8.8.8 superuser.com
Run Code Online (Sandbox Code Playgroud)
The*_*Wiz 267
对于基本的 A 和 CNAME 记录,你可以简单地做
nslookup somewhere.com some.dns.server
Run Code Online (Sandbox Code Playgroud)
Usage:
nslookup [-opt ...] # interactive mode using default server
nslookup [-opt ...] - server # interactive mode using 'server'
nslookup [-opt ...] host # just look up 'host' using default server
nslookup [-opt ...] host server # just look up 'host' using 'server'
Run Code Online (Sandbox Code Playgroud)
或者如果你只输入 nslookup 而不带任何参数,你可以做更多的选择......
Commands: (identifiers are shown in uppercase, [] means optional)
NAME - print info about the host/domain NAME using default server
NAME1 NAME2 - as above, but use NAME2 as server
help or ? - print info on common commands
set OPTION - set an option
all - print options, current server and host
[no]debug - print debugging information
[no]d2 - print exhaustive debugging information
[no]defname - append domain name to each query
[no]recurse - ask for recursive answer to query
[no]search - use domain search list
[no]vc - always use a virtual circuit
domain=NAME - set default domain name to NAME
srchlist=N1[/N2/.../N6] - set domain to N1 and search list to N1,N2, etc.
root=NAME - set root server to NAME
retry=X - set number of retries to X
timeout=X - set initial time-out interval to X seconds
type=X - set query type (ex. A,AAAA,A+AAAA,ANY,CNAME,MX,NS,PTR,SOA,SRV)
querytype=X - same as type
class=X - set query class (ex. IN (Internet), ANY)
[no]msxfr - use MS fast zone transfer
ixfrver=X - current version to use in IXFR transfer request
server NAME - set default server to NAME, using current default server
lserver NAME - set default server to NAME, using initial server
root - set current default server to the root
ls [opt] DOMAIN [> FILE] - list addresses in DOMAIN (optional: output to FILE)
-a - list canonical names and aliases
-d - list all records
-t TYPE - list records of the given RFC record type (ex. A,CNAME,MX,NS,PTR etc.)
view FILE - sort an 'ls' output file and view it with pg
exit - exit the program
Run Code Online (Sandbox Code Playgroud)
Ant*_*yko 13
只需深入研究 nslookup 的选项,如果您调用nslookup然后help在 nslookup 交互模式中输入,您就可以显示这些选项给了我正确的答案:
C:\Documents and Settings\Anton Daneyko>nslookup help
Server: DNSs2.Uni-Marburg.DE
Address: 137.248.21.22
*** DNSs2.Uni-Marburg.DE can't find help: Non-existent domain
C:\Documents and Settings\Anton Daneyko>nslookup
Default Server: DNSs2.Uni-Marburg.DE
Address: 137.248.21.22
> stackoverflow.com 8.8.8.8
Server: [8.8.8.8]
Address: 8.8.8.8
Non-authoritative answer:
Name: stackoverflow.com
Address: 64.34.119.12
Run Code Online (Sandbox Code Playgroud)
Bed*_*ara 10
是的,
C:\Documents and Settings\Anton Daneyko>nslookup superuser.com
将查找您自己的 DNS 服务器以找出 superuser.com 的 IP 地址。如果您在命令行中添加 ip 地址或不同 DNS 服务器的名称,它将查找给定的 DNS 服务器以获取 superuser.com 的 ip 地址。前任:
C:\Documents and Settings\Anton Daneyko>nslookup superuser.com 8.8.4.4
Server: google-public-dns-b.google.com
Address: 8.8.4.4
Non-authoritative answer:
Name: superuser.com
Addresses: 190.93.245.58
190.93.246.58
141.101.114.59
190.93.247.58
190.93.244.58
Run Code Online (Sandbox Code Playgroud)
顺便说一下,8.8.4.4 是谷歌 DNS 服务器的 IP 地址。
但是,以上两者都给出了“非权威答案”,因为它们都不是 SOA,它是 superuser.com 域的权威。两者都有一个从 SOA 传播的缓存副本。如果要询问权威服务器,首先要找出权威服务器的ip地址名称,使用命令:
C:\Documents and Settings\Anton Daneyko>nslookup -type=ns superuser.com
Server: DNSs2.Uni-Marburg.DE
Address: 137.248.21.22
Non-authoritative answer:
superuser.com nameserver = cf-dns02.superuser.com
superuser.com nameserver = cf-dns01.superuser.com
cf-dns02.superuser.com internet address = 173.245.59.4
cf-dns02.superuser.com AAAA IPv6 address = 2400:cb00:2049:1::adf5:3b04
cf-dns01.superuser.com AAAA IPv6 address = 2400:cb00:2049:1::adf5:3a35
cf-dns01.superuser.com internet address = 173.245.58.53
Run Code Online (Sandbox Code Playgroud)
这将从您的本地 DNS 服务器返回一个非权威答案,来自 Marburg Uni,为 superuser.com 命名所有权威服务器。然后就可以使用我们之前使用的命令询问4个权威服务器中的任意一个,如下:
C:\Documents and Settings\Anton Daneyko>nslookup superuser.com 173.245.59.4
Server: cf-173-245-59-4.cloudflare.com
Address: 173.245.59.4
Name: superuser.com
Addresses: 141.101.114.59
190.93.246.58
190.93.245.58
190.93.247.58
190.93.244.58
Run Code Online (Sandbox Code Playgroud)
如您所见,这次权威 SOA 服务器返回了 ip 地址,因此您不会再看到“非权威答案”评论。当您创建新域名或更改托管服务提供商或转移到其他域名注册商而您无法访问您的网站时,这尤其有用,因为新 IP 地址即使在 24 小时后仍未传播。然后,您可以从 SOA 开始,并验证 DNS 服务器是否提供了正确的 IP 地址,然后在树中进一步跟踪它。很高兴检查 Google DNS 服务器是否已收到更改,然后最后检查您的本地 DNS 服务器是否可以将您的域名解析为正确的 IP 地址。
要使用您指定的 DNS 服务器查找 nslookup 返回的默认 A 和 AAAA(以及 CNAME)记录以外的记录类型:
nslookup -q=<record type> <host> <DNS server>
Run Code Online (Sandbox Code Playgroud)
例如,要stackexchange.com使用 DNS 服务器返回域的 MX 记录8.8.4.4,命令为:
nslookup -q=MX stackexchange.com 8.8.4.4
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
717741 次 |
| 最近记录: |