Skip to main content

Port Forwarding

The client allows you to easily set up port forwarding through client-to-agent connections, enabling you to connect to various services such as RDP.

To perform port forwarding you can run narrowlink forward command. This command will forward the traffic from a local port to a remote port through the agent network.

narrowlink forward --help
Create a forward tunnel

narrowlink forward [OPTIONS] <remote_addr:remote_port>

Creates a tunnel between agent and client

narrowlink forward -n <agent name> <remote_addr:remote_port>
narrowlink f -un <agent name> <remote_addr:remote_port>

-d, --direct Direct connection to the remote endpoint (peer-to-peer)
-r, --relay Relay connection to the remote endpoint (peer-to-gateway-to-peer)
-u, --udp Use UDP instead of TCP
-n, --name= The name of the agent (required)
-k, --key= The secret key for end-to-end encryption
-l, --local= The local address and port to bind

As an example, let's assume that you want to forward RDP traffic from a remote machine to your local machine. To do this, you need to run the following command on your local machine:

narrowlink forward -k <secret> -n <agent_name> -l <local_ip>:<local_port> <remote_ip>:<remote_port>
  • <secret>: The passphrase for End-to-end encryption. Choose a strong and secure passphrase.
  • <agent_name>: The name of the agent. Choose a descriptive name for easy identification.
  • <local_ip>: The local IP address you want to bind for forwarding. This is the IP address of your local machine.
  • <local_port>: The local port number you want to use for forwarding. Choose an available port number.
  • <remote_ip>: The IP address of the remote machine running a service.
  • <remote_port>: The port number of the remote machine.

So the command will be like this:

narrowlink forward -k mysecret -n office -l

Now, you can use your RDP client to connect to the local IP address and port number you specified in the command. This will forward the RDP traffic to the remote machine and establish the RDP connection.

Well done! You have successfully learned and set up port forwarding for RDP using the Narrowlink client.