# Cheatsheet & Examples: nslookup

## Looking up Hostname
Example Usage:
`nslookup example.com`

What it does:
This operation retrieves the IP address associated with a given hostname.

Command-line Arguments Explained:
- example.com: The hostname to be looked up. This can be a domain name or a subdomain.

## Querying for IP Address
Example Usage:
`nslookup 8.8.8.8`

What it does:
This operation retrieves the hostname associated with a given IP address.

Command-line Arguments Explained:
- 8.8.8.8: The IP address to be looked up.

## Setting Query Type
Example Usage:
`nslookup -type=mx example.com`

What it does:
This operation retrieves the mail exchange (MX) records associated with a given hostname.

Command-line Arguments Explained:
- -type=mx: Specifies the query type. Common types include A (IP address), MX (mail exchange), NS (name server), and SOA (start of authority).
- example.com: The hostname to be looked up.

## Using a Specific DNS Server
Example Usage:
`nslookup -server=8.8.8.8 example.com`

What it does:
This operation retrieves the IP address associated with a given hostname using a specified DNS server.

Command-line Arguments Explained:
- -server=8.8.8.8: Specifies the DNS server to use for the lookup. This can be an IP address or a hostname.
- example.com: The hostname to be looked up.

## Looking up a SoA Record
Example Usage:
`nslookup -type=soa example.com`

What it does:
This operation retrieves the start of authority (SOA) record associated with a given hostname.

Command-line Arguments Explained:
- -type=soa: Specifies the query type as SOA (start of authority).
- example.com: The hostname to be looked up.

## Using a Non-Routing DNS Server
Example Usage:
`nslookup -ns=8.8.8.8 example.com`

What it does:
This operation retrieves the IP address associated with a given hostname using a non-routing DNS server.

Command-line Arguments Explained:
- -ns=8.8.8.8: Specifies the non-routing DNS server to use for the lookup. This can be an IP address or a hostname.
- example.com: The hostname to be looked up.

## Setting the Port Number
Example Usage:
`nslookup -port=53 example.com`

What it does:
This operation retrieves the IP address associated with a given hostname using a specified port number.

Command-line Arguments Explained:
- -port=53: Specifies the port number to use for the DNS query. The default port number is 53.
- example.com: The hostname to be looked up.

## Looking up a PTR Record
Example Usage:
`nslookup -type=ptr 8.8.8.8`

What it does:
This operation retrieves the pointer (PTR) record associated with a given IP address.

Command-line Arguments Explained:
- -type=ptr: Specifies the query type as PTR (pointer).
- 8.8.8.8: The IP address to be looked up.

## Using the +options Flag
Example Usage:
`nslookup +options example.com`

What it does:
This operation retrieves the IP address associated with a given hostname with additional options.

Command-line Arguments Explained:
- +options: Enables additional options for the nslookup command. The specific options depend on the version of nslookup being used.
- example.com: The hostname to be looked up.
