nslookup命令示例教程

nslookup is a very powerful tool used to get DNS realted information from DNS servers. We can get web server IP address, Mail Server IP address, Alternative IP addresses, DNS Management Information etc from DNS servers with the nslookup command.

nslookup是一个非常强大的工具,可用于从DNS服务器获取DNS真实信息。 我们可以使用nslookup命令从DNS服务器获取Web服务器IP地址,邮件服务器IP地址,备用IP地址,DNS管理信息等。

查询和打印类型记录 (Query and Print A Type Records)

We will start with a simple and general example. We will query and list the A type of records. A type record is used to get an IP Address from the domain name. In this example, we will query for the IP address of poftut.com.

我们将从一个简单而通用的示例开始。 我们将查询并列出A类型的记录。 类型记录用于从域名中获取IP地址。 在此示例中,我们将查询poftut.com的IP地址。

$ nslookup poftut.com
Query and Print A Type Records
Query and Print A Type Records
查询和打印类型记录

We see that the IP Address of the poftut.com is 45.79.133.118 . This query is sent to the name server 127.0.0.1 which is localhost because local daemon for DNS is used.

我们看到poftut.com的IP地址是45.79.133.118。 该查询被发送到名称服务器127.0.0.1,该名称服务器为localhost,因为使用了DNS的本地守护程序。

查询和打印NS类型记录 (Query and Print NS Type Records)

Every domain has a domain name server. Domain name servers are used to store domain name configuration. A single domain may have multiple domain servers for reliability and backup purposes. Domain name servers can be stored as ns type records. We can specify domain name servers with the -type and ns like below.

每个域都有一个域名服务器。 域名服务器用于存储域名配置。 单个域可能具有多个域服务器,以实现可靠性和备份目的。 域名服务器可以存储为ns类型的记录。 我们可以使用-typens来指定域名服务器,如下所示。

$ nslookup -type=ns poftut.com
Query and Print NS Type Records
Query and Print NS Type Records
查询和打印NS类型记录

查询和打印SOA记录(Query and Print SOA Record)

Domain names are assigned to the organizations and have some configuration about their usage. This information is stored in the Start of Authority records a.k.a. SOA. We can query and print SOA record with the soa type like below.

域名已分配给组织,并对其使用进行了一些配置。 此信息存储在“授权开始”记录(又名SOA)中。 我们可以使用以下soa类型查询和打印SOA记录。

$ nslookup -type=soa poftut.com
Query and Print SOA Record
Query and Print SOA Record
查询和打印SOA记录

We can see that the following information is provided by the DNS SOA record.

我们可以看到DNS SOA记录提供了以下信息。

  • origin provides the SOA information origin which is given domain primary DNS server which is `ns1.linode.com` in this example

    origin提供了SOA信息来源,该来源是域主DNS服务器,在此示例中为“ ns1.linode.com”
  • `mail addr` is the used to provide the mail address of the domain owner

    mail addr用于提供域所有者的邮件地址
  • `serial` is the serial number of the domain name which is generally the date and time which is 2016082817 in this example

    “ serial”是域名的序列号,通常是日期和时间,在此示例中为2016082817
  • `refresh` provides the refresh time which is used by other DNS servers

    refresh提供其他DNS服务器使用的刷新时间
  • `retry`

    重试
  • `expire`

    过期
  • `minimum`

    `最低`
LEARN MORE  How to Find Detailed Domain Information with whois Command?
了解更多信息如何使用whois命令查找详细的域信息?

查询和打印MX记录 (Query and Print MX Records)

DNS servers also provide the main server IP address with the MX type records. We can find mail server name of the given record with the following command.

DNS服务器还提供带有MX类型记录的主服务器IP地址。 我们可以使用以下命令找到给定记录的邮件服务器名称。

$ nslookup -type=mx poftut.com
Query and Print MX Records
Query and Print MX Records
查询和打印MX记录

查询和打印所有DNS记录(Query and Print All DNS Records)

Up to now, we have checked different DNS types by specifying them with  -type option. We can also check all of these DNS record types with a single command. We will provide any values to the -typeoption like below.

到目前为止,我们已经通过-type选项指定了不同的DNS类型。 我们还可以使用单个命令检查所有这些DNS记录类型。 我们将为-type选项提供any值,如下所示。

$ nslookup -type=any poftut.com
Query and Print All DNS Records
Query and Print All DNS Records
查询和打印所有DNS记录

查询并检查特定的DNS服务器(Query and Check Specific DNS Server)

The default behavior of the nslookup command is to check the default DNS server for the given query. We can also specify the DNS server we want to check. We will just add DNS server name to the end of the command. In this example, we will check DNS server ns2.linode.com for the domain name poftut.com.

nslookup命令的默认行为是检查给定查询的默认DNS服务器。 我们还可以指定我们要检查的DNS服务器。 我们仅将DNS服务器名称添加到命令末尾。 在此示例中,我们将检查DNS服务器ns2.linode.com中的域名poftut.com

$ nslookup poftut.com ns2.linode.com
Query and Check Specific DNS Server
Query and Check Specific DNS Server
查询并检查特定的DNS服务器

查询反向DNS查找(Query Reverse DNS Lookup)

Up to now we have queried given a domain name and get the IP address. But in some cases, we may need to get the domain name by providing the IP address. This type of query is named as reverse DNS lookup. We can query the domain name of the IP address by just providing the IP address to the nslookup command like below.

到目前为止,我们已经查询了给定的域名并获得了IP地址。 但是在某些情况下,我们可能需要通过提供IP地址来获取域名。 这种查询称为反向DNS查找。 我们可以通过仅向nslookup命令提供IP地址来查询IP地址的域名,如下所示。

$ nslookup 45.79.133.118
Query Reverse DNS Lookup
Query Reverse DNS Lookup
查询反向DNS查找

查询指定的DNS服务器端口(Query Specified DNS Server Port)

DNS servers use TCP or UDP port 53 by default. So while using nslookup we do not need to specify the port number of the remote DNS server. If we know that given DNS server uses a different port then 53 we can specify DNS service port explicitly with the -port option.

默认情况下,DNS服务器使用TCP或UDP端口53。 因此,在使用nslookup时,我们无需指定远程DNS服务器的端口号。 如果我们知道给定的DNS服务器使用其他端口,则可以使用-port选项明确指定DNS服务端口53。

$ nslookup -port=100 poftut.com

使用调试模式打印详细信息 (Print Details with Debug Mode)

During a DNS server lookup, there will be a lot of actions which is not shown by default. If there is a problem or we want to check these actions we need to show verbose output with the debug mode. We will use -debug option to print detailed information about nslookup.

在DNS服务器查找期间,将有很多动作(默认情况下未显示)。 如果有问题或我们要检查这些操作,则需要在调试模式下显示详细的输出。 我们将使用-debug选项来打印有关nslookup的详细信息。

$ nslookup -debug poftut.com
Print Details with Debug Mode
Print Details with Debug Mode
使用调试模式打印详细信息

翻译自: https://www.poftut.com/nslookup-commands-tutorial-with-examples/

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值