> For the complete documentation index, see [llms.txt](https://sec88.0x88.online/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sec88.0x88.online/network-sec/port-redirection-and-tunneling.md).

# Port Redirection and Tunneling

### SSH Local Port Forwarding

* **On Attacker Machine:**
  * Use the following command to establish local port forwarding:

    ```bash
    sudo ssh -L localhost:local-port:target:remote-port user@mediator
    ```
  * Replace `localhost`, `local-port`, `target`, `remote-port`, `user`, and `mediator` with appropriate values.
  * This redirects traffic from the local machine's `local-port` to the `target:remote-port` through the `mediator` machine.

### SSH Remote Port Forwarding

* **On Victim Machine:**
  * Use the following command to establish remote port forwarding:

    ```bash
    sudo ssh -R 8080:127.0.0.1:80 kali@192.168.1.15
    ```
  * Replace `8080`, `127.0.0.1:80`, `kali`, and `192.168.1.15` with appropriate values.
  * This redirects traffic from the victim machine's `127.0.0.1:80` to the attacker's machine on port `8080`.

### SSH Dynamic Port Forwarding

* Use the following command to establish dynamic port forwarding:

  ```bash
  ssh -D 8080 user@ip
  ```

  * Replace `8080`, `user`, and `ip` with appropriate values.
  * This creates a dynamic SOCKS proxy on the local machine, redirecting traffic through the specified SSH server.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://sec88.0x88.online/network-sec/port-redirection-and-tunneling.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.
