nslookup

语法:

nslookup [-qt=类型] 目标域名 [指定的DNS服务器IP或域名]

1 直接查询

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

nslookup domain [dns-server]

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

[root@localhost ~]# nslookup baidu.com
Server:     10.30.7.177
Address:    10.30.7.177#53

Non-authoritative answer:
Name:   baidu.com
Address: 123.125.114.144
Name:   baidu.com
Address: 111.13.101.208
Name:   baidu.com
Address: 180.149.132.47
Name:   baidu.com
Address: 220.181.57.217

2 查询其他记录

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

nslookup -qt=type domain [dns-server]

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

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

例如:

[root@localhost ~]# nslookup -qt=mx baidu.com 8.8.8.8
*** Invalid option: qt=mx
Server:     8.8.8.8
Address:    8.8.8.8#53

Non-authoritative answer:
Name:   baidu.com
Address: 111.13.101.208
Name:   baidu.com
Address: 123.125.114.144
Name:   baidu.com
Address: 180.149.132.47
Name:   baidu.com
Address: 220.181.57.217

3 查询更具体的信息

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

nslookup –d [其他参数] domain [dns-server]
C:\Users\Administrator>nslookup -d2 -qt=ns itlearning.club
------------
SendRequest(), len 38
    HEADER:
        opcode = QUERY, id = 1, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        8.8.8.8.in-addr.arpa, type = PTR, class = IN

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

    QUESTIONS:
        8.8.8.8.in-addr.arpa, type = PTR, class = IN
    ANSWERS:
    ->  8.8.8.8.in-addr.arpa
        type = PTR, class = IN, dlen = 32
        name = google-public-dns-a.google.com
        ttl = 19395 (5 hours 23 mins 15 secs)

------------
服务器:  google-public-dns-a.google.com
Address:  8.8.8.8

------------
SendRequest(), len 33
    HEADER:
        opcode = QUERY, id = 2, rcode = NOERROR
        header flags:  query, want recursion
        questions = 1,  answers = 0,  authority records = 0,  additional = 0

    QUESTIONS:
        itlearning.club, type = NS, class = IN

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

    QUESTIONS:
        itlearning.club, type = NS, class = IN
    ANSWERS:
    ->  itlearning.club
        type = NS, class = IN, dlen = 16
        nameserver = ns1.dnsowl.com
        ttl = 21013 (5 hours 50 mins 13 secs)
    ->  itlearning.club
        type = NS, class = IN, dlen = 6
        nameserver = ns2.dnsowl.com
        ttl = 21013 (5 hours 50 mins 13 secs)
    ->  itlearning.club
        type = NS, class = IN, dlen = 6
        nameserver = ns3.dnsowl.com
        ttl = 21013 (5 hours 50 mins 13 secs)

------------
非权威应答:
itlearning.club
        type = NS, class = IN, dlen = 16
        nameserver = ns1.dnsowl.com
        ttl = 21013 (5 hours 50 mins 13 secs)
itlearning.club
        type = NS, class = IN, dlen = 6
        nameserver = ns2.dnsowl.com
        ttl = 21013 (5 hours 50 mins 13 secs)
itlearning.club
        type = NS, class = IN, dlen = 6
        nameserver = ns3.dnsowl.com
        ttl = 21013 (5 hours 50 mins 13 secs)

C:\Users\Administrator>

4 windows下的nslookup

当有记录时返回如下

C:\Users\Administrator>nslookup -qt=cname pop.itlearning.club
服务器:  google-public-dns-a.google.com
Address:  8.8.8.8

非权威应答:
pop.itlearning.club     canonical name = mail.itlearning.club

 当没有记录时,默认返回如下

C:\Users\Administrator>nslookup -qt=ns smtp.itlearning.club
服务器:  google-public-dns-a.google.com
Address:  8.8.8.8

itlearning.club
        primary name server = ns1.dnsowl.com
        responsible mail addr = hostmaster.dnsowl.com
        serial  = 1542635886
        refresh = 7200 (2 hours)
        retry   = 1800 (30 mins)
        expire  = 1209600 (14 days)
        default TTL = 600 (10 mins)

C:\Users\Administrator>nslookup -qt=ns itlearning.club
服务器:  google-public-dns-a.google.com
Address:  8.8.8.8

非权威应答:
itlearning.club nameserver = ns1.dnsowl.com
itlearning.club nameserver = ns2.dnsowl.com
itlearning.club nameserver = ns3.dnsowl.com

C:\Users\Administrator>

 当然也可以换种格式,

C:\Users\Administrator>nslookup
默认服务器:  google-public-dns-a.google.com
Address:  8.8.8.8

> set type=txt
> mail.itlearning.club
服务器:  google-public-dns-a.google.com
Address:  8.8.8.8

itlearning.club
        primary name server = ns1.dnsowl.com
        responsible mail addr = hostmaster.dnsowl.com
        serial  = 1542635286
        refresh = 7200 (2 hours)
        retry   = 1800 (30 mins)
        expire  = 1209600 (14 days)
        default TTL = 600 (10 mins)

 

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值