# Local Port Forwards

![](/files/AKUlmgAux0inwq5dJL3D)

```shell
# Local Port Forwarding (using rinetd)

# Target Machine // 10.0.0.1
Python -m SimpleHTTPServer 80

# Gateway Machine
apt-get install rinetd
nano /etc/rinetd.conf
    localhost    localport    remotehost    remoteport     
    127.0.0.1    53            10.0.0.1    80

# Kali Machine // http://gatway:53 → http://10.0.0.1:80
```

```shell
# Local Port Forwarding (using netcat)

# Target Machine // 10.0.0.1
nc -lnvp 22

# Gateway Machine
mknod relaynode p
nc -lvnp 1111 0<relaynode | nc 10.0.0.1 22 1>relaynode

# Kali Machine
nc gateway 1111
```

```shell
# Local Port Forwarding (using SSH)

# Target Machine // 10.0.0.1
Python -m SimpleHTTPServer 80

# Gateway Machine
nano /etc/ssh/sshd_config
    Port 53

# Kali Machine
// Now we will connect to the gateway through ssh on port 53, then we will connect
// port 8080 on the internal machine with port 80 on the web server machine. 
ssh user@gateway -p 53 -L 127.0.0.1:8080:10.0.0.1:80
// Now browse to http://127.0.0.1:8080 -> http://10.0.0.1:80
```


---

# 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://hsaad.gitbook.io/x/red-teaming/pivoting-and-forwarding/local-port-forwards.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.
