Home >Operation and Maintenance >Linux Operation and Maintenance >Linux nslookup command help and DNS lookup examples

Linux nslookup command help and DNS lookup examples

不言
不言Original
2019-03-13 10:24:145786browse

nslookup stands for "name server lookup" and is a useful command for obtaining information from DNS servers. It is also very useful for troubleshooting DNS related issues and can query the DNS (Domain Name Server) and get the DNS records for any domain for the IP address.

Linux nslookup command help and DNS lookup examples

DNS lookup example

Use the following command to find the address record for a domain. It queries the nameservers and gets the details.

# nslookup google.com
Server:         8.8.8.8
Address:        8.8.8.8#53
Non-authoritative answer:
Name:   google.com
Address: 216.58.219.206

Reverse DNS lookup

You can also use the IP address for reverse DNS lookup, and you can use the IP address to resolve the corresponding domain. Note that this is a different record configured in the reverse zone of the domain.

# nslookup 216.58.219.206
Server:         8.8.8.8
Address:        8.8.8.8#53
Non-authoritative answer:
206.219.58.216.in-addr.arpa     name = lga25s40-in-f14.1e100.net.
206.219.58.216.in-addr.arpa     name = lga25s40-in-f14.1e100.net.
206.219.58.216.in-addr.arpa     name = lga25s40-in-f206.1e100.net.
206.219.58.216.in-addr.arpa     name = lga25s40-in-f206.1e100.net.

Query a specific DNS server

You can also query a specific DNS server. Additional parameters need to be passed for the nameserver IP address or domain name. For example, to query the 8.8.4.4 name server, use the following command.

# nslookup google.com 8.8.4.4
Server:         8.8.4.4
Address:        8.8.4.4#53
Non-authoritative answer:
Name:   google.com
Address: 216.58.219.206

Find the SOA record for a domain

Use nslookup to find the SOA (Start of Authorization) record for any domain. For example, to find the SOA records for the domain google.com, you can use the following command. Type-type=soa needs to be specified as a command line parameter.

# nslookup -type=soa google.com
Server:         8.8.8.8
Address:        8.8.8.8#53
Non-authoritative answer:
google.com
        origin = ns4.google.com
        mail addr = dns-admin.google.com
        serial = 159912615
        refresh = 900
        retry = 900
        expire = 1800
        minimum = 60
Authoritative answers can be found from:

origin: The authority of the source of information.

mail addr: The email address of the domain administrator (the first dot represents the @ symbol in the email address).

serial: Revision data of the domain area, in the format of YYYYMMDDNN.

refresh: The referh interval (in seconds) at which the secondary name server will check the primary name server for updated versions of the zone.

retry: The time to wait for a secondary name server before trying to reconnect to the primary name server after a failed attempt.

expire: The time in seconds for the secondary name server cache to expire.

minimum: The time in seconds that the secondary name server's cache should not be flushed if no time has elapsed since the last flush.

Find a domain’s MX records

You can also query the MX (Mail Exchange) records for any domain, which are responsible for the delivery of email.

# nslookup -query=mx google.com
Server:         8.8.8.8
Address:        8.8.8.8#53
Non-authoritative answer:
google.com      mail exchanger = 10 aspmx.l.google.com.
google.com      mail exchanger = 30 alt2.aspmx.l.google.com.
google.com      mail exchanger = 50 alt4.aspmx.l.google.com.
google.com      mail exchanger = 40 alt3.aspmx.l.google.com.
google.com      mail exchanger = 20 alt1.aspmx.l.google.com.
Authoritative answers can be found from:

Finding TXT records for a domain

TXT records are useful for many types of records (such as DKIM, SPF, etc.). You can use the command below to find all TXT records configured for any domain.

# nslookup -query=txt google.com
Server:         8.8.8.8
Address:        8.8.8.8#53
Non-authoritative answer:
google.com      text = "v=spf1 include:_spf.google.com ~all"
Authoritative answers can be found from:

Find all records for a domain

Use -query=any to list all records for any domain.

# nslookup -query=any google.com
Server:         8.8.8.8
Address:        8.8.8.8#53
Non-authoritative answer:
Name:   google.com
Address: 216.58.219.206
google.com      has AAAA address 2607:f8b0:4006:80e::200e
google.com      mail exchanger = 20 alt1.aspmx.l.google.com.
google.com      mail exchanger = 40 alt3.aspmx.l.google.com.
google.com      nameserver = ns2.google.com.
google.com      nameserver = ns4.google.com.
google.com      nameserver = ns3.google.com.
google.com      rdata_257 = 0 issue "pki.goog"
google.com      mail exchanger = 30 alt2.aspmx.l.google.com.
google.com      mail exchanger = 10 aspmx.l.google.com.
google.com      mail exchanger = 50 alt4.aspmx.l.google.com.
google.com      text = "v=spf1 include:_spf.google.com ~all"
google.com      nameserver = ns1.google.com.
google.com      rdata_257 = 0 issue "symantec.com"
google.com
        origin = ns2.google.com
        mail addr = dns-admin.google.com
        serial = 159912615
        refresh = 900
        retry = 900
        expire = 1800
        minimum = 60
Authoritative answers can be found from:

Nslookup in interactive mode

We can also use nslookup in interactive mode. To enter interactive mode, type nslookup on the console and press Enter. You will get an nslookup prompt such as >. Here, you can run the same query and get the domain's information from the DNS server. Comments have been added between commands for better understanding.

root@tecadmin:~#nslookup
### Type domain name to get information from dns server 
> google.com
Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.10.46

### Set the another specific dns server to query. 
> server 8.8.4.4 
Default server: 8.8.4.4
Address: 8.8.4.4#53

### Again try to get the dns information, This time nslookup connects to specified dns server. 
> google.com 
Server:         8.8.4.4
Address:        8.8.4.4#53

Non-authoritative answer:
Name:   google.com
Address: 172.217.10.46

### Set the query type. for example to get MX information set query=mx 
> set query=mx 

### Again try to get the dns information, This time nslookup will show MX information for domain 
> google.com 
Server:         8.8.4.4
Address:        8.8.4.4#53

Non-authoritative answer:
google.com      mail exchanger = 30 alt2.aspmx.l.google.com.
google.com      mail exchanger = 50 alt4.aspmx.l.google.com.
google.com      mail exchanger = 40 alt3.aspmx.l.google.com.
google.com      mail exchanger = 10 aspmx.l.google.com.
google.com      mail exchanger = 20 alt1.aspmx.l.google.com.

Authoritative answers can be found from:

This article has ended here. For more exciting content, you can pay attention to other related column tutorials on the php Chinese website! ! !

The above is the detailed content of Linux nslookup command help and DNS lookup examples. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn