Skip to main content

Connect to a Remote Service with WebRelay

In many networked environments, services might be guarded behind security mechanisms such as a firewall, NAT (Network Address Translation), or VPN (Virtual Private Network). To access such services, one might need a secured and temporary connection method.

WebRelay offers an easy solution to get temporary access to these protected services. It's distinct from other tools because, by default, it doesn’t expose a tunnel on the public internet. Instead, WebRelay establishes a secure connection between your local machine and the remote service, making the service seem as if it's running on your local machine.

How WebRelay Works

  1. On the remote machine: Register your service with WebRelay.
  2. On your local machine: Connect to the remote service and bind it to a local port using WebRelay. The service now feels local to you.

Walkthrough: Setting Up a Simple Echo Service

1. On the Remote Machine

Step 1: Start an Echo Service Using Netcat

nc -l 12345 -k -c 'xargs -n1 echo'
  • -l: Instructs netcat to listen for incoming connections.
  • 12345: The designated port number for the service.
  • -k: Makes netcat wait for another connection once the current one ends.
  • -c 'xargs -n1 echo': Constructs a basic echo service. It reads inputs line-by-line and sends them back.

Step 2: Register the Service with WebRelay

webrelay service start -p 12345 -n echo -t tcp -u 127.0.0.1
  • -n echo: Names the service as 'echo'.
  • -t tcp: Specifies the service type as TCP (you can also use -t http for HTTP services).
  • -u 127.0.0.1: Designates the upstream host.
  • -p 12345: Provides the port number of the upstream service (please note there's a discrepancy in the original port number mentioned, 5432).

2. On Your Local Machine

Step 1: View Your Services

webrelay service list

You should see the 'echo' service:

service list

Step 2: Connect to the Remote Service

webrelay client -n echo -p 9000

This command maps the remote 'echo' service to your local port 9000.

Step 3: Test the Connection

Using telnet, connect to the local port:

telnet localhost 9000

Your echo service is now accessible on your machine as if it's a local service.

Remember, you can press Ctrl+C anytime to terminate the service, which will also close all active connections.