41

nslookup的基本使用

 4 years ago
source link: https://www.tuicool.com/articles/mUBFvuN
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

nslookup的基本使用

nslookup:name server lookup 用来查询DNS的。

1:安装nslookup命令

[root@localhost ~]#  yum install bind-utils       #bind-utils包含了host,dig,nslookup等命令

2:nslookup两种模式

交互模式 非交互模式 nslookup 只需要执行一次nslookup命令,就可以像域名服务器发起连续的查询请求 用户发起的查询是一次性的

交互模式演示:

[root@localhost ~]# nslookup               #使用/etc/resolv.conf第一行所配置的域名服务器来查询
> 
[root@localhost ~]# nslookup - 8.8.8.8     #指定8.8.8.8的域名服务器来查询
> 
[root@localhost ~]# nslookup - 8.8.8.8      #指定8.8.8.8的域名服务器来查询www.baidu.com的ip地址
> www.baidu.com
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
www.baidu.com   canonical name = www.a.shifen.com.
Name:   www.a.shifen.com
Address: 183.232.231.172
Name:   www.a.shifen.com
Address: 183.232.231.174
>

非交互模式演示:

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

Non-authoritative answer:
www.baidu.com   canonical name = www.a.shifen.com.
Name:   www.a.shifen.com
Address: 183.232.231.172
Name:   www.a.shifen.com
Address: 183.232.231.174

[root@localhost ~]# 
##Non-authoritative answer :从本机缓存种获取的DNS解析数据就是非授权的,因为DNS缓存有时间差,不一定保证本机缓存的是最新的数据。

3:nslookup输出解析

上半部分:DNS服务器信息

下半部分:域名解析信息

[root@localhost ~]# nslookup www.baidu.com
Server:         192.168.3.1      #本次DNS解析所使用的DNS服务器,默认使用/etc/resolv.conf第一个DNS服务器
Address:        192.168.3.1#53   #连接到的DNS服务器的具体ip地址和端口

Non-authoritative answer:
www.baidu.com   canonical name = www.a.shifen.com.    #CNAME,别名
Name:   www.a.shifen.com
Address: 183.232.231.172                              #百度真正对应的ip地址1
Name:   www.a.shifen.com
Address: 183.232.231.174                            #百度真正对应的ip地址1

4.DNS协议中的五元组

{DomainName,TimeToLive,Class,Type,Value}

域名 生存期限 类别 类型 值 指我们查询的那个域名 此域名在各个DNS服务器中应保存的时长 IN,即Internet 指出这条记录的类型
包括8种,即SOA,A,MX,NS,CNAME,PTR,HINFO和TXT。 根据不同的类型,会有不同的值

8种类型的解释:

SOA A MX NS CNAME PTR HINFO TXT start of authority,授权起始,我们可以获取一个域名最基本的信息:
Mail:管理员邮箱地址
Serial:版本序号
Refresh Slave:表示Slave的DNS服务器多久向Master的DNS服务器要一次更新数据
Retry:在发起Refresh时,如果Slave连接不到Master,那么间隔多久进行一次连接尝试
Expire:在发起Refresh时,如果Slave始终无法连接到Master,那么多久后放弃尝试
Minimum:即TTL,表示外部DNS服务器如果要缓存本DNS服务器的授权数据,那么要保存多久 表示从域名解析到IP地址,此处用于展示其对应的IP地址信息 Mail eXchange,即邮件交换。用来表示当前域名对应的邮件服务器,如果当前没有配置对应的邮件服务器,则MX为空 Name Server,表示给定域名下所包含的DNS服务器信息 canonical name,别名 指针,用来表示反解信息 包含cpu和os信息 文本信息

演示如下:

[root@localhost ~]# nslookup -type=soa www.baidu.com  
Server:         192.168.3.1
Address:        192.168.3.1#53

Non-authoritative answer:
www.baidu.com   canonical name = www.a.shifen.com.

Authoritative answers can be found from:
a.shifen.com
        origin = ns1.a.shifen.com
        mail addr = baidu_dns_master.baidu.com
        serial = 1910010002
        refresh = 5
        retry = 5
        expire = 2592000
        minimum = 3600
        
[root@localhost ~]# nslookup -type=ip  www.baidu.com
unknown query type: ip
Server:         192.168.3.1
Address:        192.168.3.1#53

Non-authoritative answer:
www.baidu.com   canonical name = www.a.shifen.com.
Name:   www.a.shifen.com
Address: 183.232.231.172
Name:   www.a.shifen.com
Address: 183.232.231.174

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK