Port Forwarding
SSH
Local Port Forward
SSH Client
listens for a connection, on a specific portWhen
SSH Client
recieves a connection, it tunnels the connection to theSSH Server
which connects to the configured destination port.Can be used to connect to Internal resource from the outside.
Example:
Opens up port on
0.0.0.0
on port90
onSSH Client
which when accessed forwards the connection to192.168.10.12
on port80
which is only accessible via192.168.10.87
Remote Port Forward
SSH Server
listens for a connection on a configured port.When the port receives the connection it forwards the connection to the
SSH Client
machine on the configured destination portCan be used to expose Client localhost to the public if
SSH Server
is available on public internet
Example:
Opens a port
8080
onmyserver.com
which forwards the incoming connection theSSH Client
's localhost on port80
Socat
Useful when SSH is not available.
Does not come preinstalled. Need to transfer socat binary to host.
Opens up port
1234
on the host machine which forwards all traffic to1.1.1.1
on port4321
.Similar to local port forwarding. Can be used to access remote servers.
SOCKS Proxy
Can port forward all port dynamically
SSH
Example:
Opens up a dynamic port
9090
onlocalhost
.We can use proxy chains to use our tools with this forwarded port.
We can edit
/etc/proxychains.conf
to configure the port.
Now we can execute any program through proxy using
proxychains
command
Last updated