# Networking cheatsheet

## Get DNS records

Using default DNS resolvers:

```bash
nslookup google.com
```

Using Cloudflare (`1.1.1.1`) DNS resolver:

```bash
nslookup google.com 1.1.1.1
```

## Setup HTTP server with netcat

Run the following to start a HTTP responder on port `5555`:

```bash
while :; do echo -e "HTTP/1.1 200 OK\nContent-Length: 3\n\n ok" | nc -l -p 5555; done
```

To verify TCP connectivity, run the above and then:

```bash
curl localhost:5555
# or
wget -qO - localhost:5555
```

## Verifying port connectivity

To verify that port `443` is open on `google.com`, use:

```bash
nc -zv google.com 443
```

Generic structure of command:

```bash
nc -zv ${HOSTNAME} ${PORT}
```


---

# 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://notes.joeir.net/system-administration/networking-cheatsheet.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.
