# nslookup

## nslookup

`nslookup` is a command-line tool used for querying the Domain Name System (DNS) to obtain domain name or IP address mapping information. It is widely used for network troubleshooting and is available on most operating systems, including Linux, macOS, and Windows.

#### Usage

```bash
nslookup [options] [domain-name | IP-address] [DNS-server]
```

* `domain-name | IP-address`: The domain name or IP address to query.
* `DNS-server`: The DNS server to use for the query. If not specified, the default DNS server configured in the system will be used.
* `options`: Additional command-line options to control the behavior of `nslookup`.

#### Common Options

* `-type=TYPE` or `-q=TYPE`: Specifies the type of DNS record to query (e.g., A, MX, NS, etc.).
* `-timeout=NUMBER`: Sets the timeout interval for the request in seconds.
* `-retry=NUMBER`: Sets the number of retries for the request.
* `-debug`: Enables debugging mode to show detailed information about the request and response.

#### Examples

1. **Basic Query**

   To query the A record for `example.com`:

   ```bash
   nslookup example.com
   ```

   Output:

   ```
   Server:         8.8.8.8
   Address:        8.8.8.8#53

   Non-authoritative answer:
   Name:   example.com
   Address: 93.184.216.34
   ```
2. **Query a Specific DNS Server**

   To query the DNS server at `8.8.8.8` for the A record of `example.com`:

   ```bash
   nslookup example.com 8.8.8.8
   ```
3. **Query for a Specific Record Type**

   To query the MX records for `example.com`:

   ```bash
   nslookup -query=MX example.com
   ```

   Output:

   ```
   Server:         8.8.8.8
   Address:        8.8.8.8#53

   Non-authoritative answer:
   example.com    mail exchanger = 10 mail.example.com.
   ```
4. **Reverse DNS Lookup**

   To perform a reverse DNS lookup for the IP address `192.0.2.1`:

   ```bash
   nslookup 192.0.2.1
   ```

   Output:

   ```
   Server:         8.8.8.8
   Address:        8.8.8.8#53

   Non-authoritative answer:
   1.2.0.192.in-addr.arpa    name = example.com.
   ```
5. **Debugging Mode**

   To enable debugging mode for more detailed output:

   ```bash
   nslookup -debug example.com
   ```

#### Benefits of Using `nslookup`

1. **Simplicity**: Easy to use for basic DNS queries.
2. **Availability**: Pre-installed on most operating systems.
3. **Flexibility**: Supports querying different types of DNS records and specific DNS servers.
4. **Debugging**: Provides detailed debugging information for advanced troubleshooting.

#### Use Cases

**Example 1: Verify Mail Server Configuration**

To check the mail exchange (MX) records for a domain:

```bash
nslookup -type=MX example.com
```

**Example 2: Check Name Server Records**

To list the authoritative name servers for a domain:

```bash
nslookup -type=NS example.com
```

**Example 3: Reverse Lookup**

To verify the hostname associated with an IP address:

```bash
nslookup 93.184.216.34
```

#### Conclusion

`nslookup` is a versatile tool for performing DNS lookups and troubleshooting DNS-related issues. It offers a straightforward interface for querying various types of DNS records and can be used to check domain name resolutions, mail server configurations, and more. Whether you are a network administrator or a developer, `nslookup` provides essential functionality for managing and diagnosing DNS issues.

## help

```
nslookup [options] hostname [server]

Options:

-?, --help     Print this help message.
-a, --all       List all records.
-c, --cache     Use the local cache.
-d, --debug      Print debugging information.
-f, --family    Set address family to AF_INET or AF_INET6.
-i, --info      List additional information about records.
-k, --keep-query Continue to query until the answer has expired.
-n, --no-cache  Do not use the local cache.
-p, --port      Set the port number to use for queries.
-r, --recurse   Recursively query for all records.
-s, --server    Specify the name server to use.
-t, --type      Specify the type of record to query.
-v, --verbose    Print verbose output.
-w, --timeout   Set the timeout value in seconds.

For more information, see the nslookup man page.
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://linux-tutorial-cli.gitbook.io/linux-cli-tutorial/txt-files/nslookup.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
