你我什么时候
有过自由

nslookup命令用法

nslookup命令用于查询DNS的记录,查看域名解析是否正常,在网络故障的时候用来诊断网络问题。nslookup的用法相对来说还是蛮简单的,主要是下面的几个用法。

1、直接查询

这个可能大家用到最多,查询一个域名的A记录。

nslookup domain [dns-server]

如果没指定dns-server,用系统默认的dns服务器。下面是一个例子:

nslookup vimetc.me 8.8.8.8
服务器: dns.google
Address: 8.8.8.8

非权威应答:
名称: vimetc.me
Addresses: 2606:4700:3033::681b:90ca
2606:4700:3034::681b:91ca
104.27.144.202
104.27.145.202

2、查询其他记录

直接查询返回的是A记录,我们可以指定参数,查询其他记录,比如AAAA、MX等。

nslookup -qt=type domain [dns-server]

其中,type可以是以下这些类型:

A 地址记录
AAAA 地址记录
AFSDB Andrew文件系统数据库服务器记录
ATMA ATM地址记录
CNAME 别名记录
HINFO 硬件配置记录,包括CPU、操作系统信息
ISDN 域名对应的ISDN号码
MB 存放指定邮箱的服务器
MG 邮件组记录
MINFO 邮件组和邮箱的信息记录
MR 改名的邮箱记录
MX 邮件服务器记录
NS 名字服务器记录
PTR 反向记录
RP 负责人记录
RT 路由穿透记录
SRV TCP服务器信息记录
TXT 域名对应的文本信息
X25 域名对应的X.25地址记录

例如:

nslookup -qt=mx vimetc.me 8.8.8.8
服务器: dns.google
Address: 8.8.8.8

vimetc.me
primary name server = aida.ns.cloudflare.com
responsible mail addr = dns.cloudflare.com
serial = 2033985504
refresh = 10000 (2 hours 46 mins 40 secs)
retry = 2400 (40 mins)
expire = 604800 (7 days)
default TTL = 3600 (1 hour)

3、查询更具体的信息

查询语法:

nslookup –d [其他参数] domain [dns-server]

只要在查询的时候,加上-d参数,即可查询域名的缓存。

nslookup -d vimetc.me

Got answer:
HEADER:
opcode = QUERY, id = 1, rcode = NOERROR
header flags: response, auth. answer, want recursion, recursion avail.
questions = 1, answers = 1, authority records = 0, additional = 0

QUESTIONS:
    1.31.168.192.in-addr.arpa, type = PTR, class = IN
ANSWERS:
->  1.31.168.192.in-addr.arpa
    name = XiaoQiang
    ttl = 0 (0 secs)

服务器: XiaoQiang
Address: 192.168.31.1


Got answer:
HEADER:
opcode = QUERY, id = 2, rcode = NOERROR
header flags: response, want recursion, recursion avail.
questions = 1, answers = 2, authority records = 0, additional = 0

QUESTIONS:
    vimetc.me, type = A, class = IN
ANSWERS:
->  vimetc.me
    internet address = 104.27.145.202
    ttl = 30 (30 secs)
->  vimetc.me
    internet address = 104.27.144.202
    ttl = 30 (30 secs)

非权威应答:

Got answer:
HEADER:
opcode = QUERY, id = 3, rcode = NOERROR
header flags: response, want recursion, recursion avail.
questions = 1, answers = 2, authority records = 0, additional = 0

QUESTIONS:
    vimetc.me, type = AAAA, class = IN
ANSWERS:
->  vimetc.me
    AAAA IPv6 address = 2606:4700:3034::681b:91ca
    ttl = 30 (30 secs)
->  vimetc.me
    AAAA IPv6 address = 2606:4700:3033::681b:90ca
    ttl = 30 (30 secs)

名称: vimetc.me
Addresses: 2606:4700:3034::681b:91ca
2606:4700:3033::681b:90ca
104.27.145.202
104.27.144.202

赞(0)

评论 4

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #1

    前排

    gabreel4个月前 (05-03)回复
  2. #2

    滑稽

    emmm4个月前 (05-04)回复
  3. #3

    珈百璃妹妹,mua
    看到xiaoqiang,我就知道,你在用小米漏油器了

    周树人4个月前 (05-05)回复

分享下

点击登机网盘