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

Linux nslookup command help and DNS lookup examples

不言
Release: 2019-03-13 10:24:14
Original
5779 people have browsed it

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
Copy after login
Server:         8.8.8.8
Address:        8.8.8.8#53
Non-authoritative answer:
Name:   google.com
Address: 216.58.219.206
Copy after login

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
Copy after login
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.
Copy after login

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
Copy after login
Server:         8.8.4.4
Address:        8.8.4.4#53
Non-authoritative answer:
Name:   google.com
Address: 216.58.219.206
Copy after login

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
Copy after login
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:
Copy after login

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
Copy after login
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:
Copy after login

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
Copy after login
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:
Copy after login

Find all records for a domain

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

# nslookup -query=any google.com
Copy after login
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:
Copy after login

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:
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template