8

I'm looking for an equivalent of this:

ssh -R 8888:10.0.0.2:8888 100.101.102.103

ie. make the service running on port 8888 on the local machine (10.0.0.2) look like a locally running service on a remote machine (100.101.102.103).

However, I don't want the encryption overhead of ssh, since the service in question is https and is thus already encrypted.

Can anyone suggest a tool to do this? Note that the direction of the initiation is important here - ie. it's the equivalent of a reverse tunnel. The local machine, where the service is running, is on a private network and not directly visible to the remote machine; the remote machine has a public IP though.

  • unix (OS X and Linux) on each end
  • I have full access to both machines
  • 1
    Google for: "tcp gender change". An article on Wikipedia: en.m.wikipedia.org/wiki/TCP_Gender_Changer. Some tools which do that on Linux: tgcd, revinetd – Fabio Nov 29 '17 at 15:34

7 Answers7

8

A pair of netcat sessions would fit the bill, I guess.

man nc

Sven
  • 98,649
  • 14
  • 180
  • 226
5

Just set ssh's encryption cypher to none.

ssh -c none -R 8888:10.0.0.2:8888 100.101.102.103
Haakon
  • 1,325
  • 7
  • 11
4

do not forget socat, the swiss army knife of network forwarders ;)

http://www.dest-unreach.org/socat/

Aleksandar Ivanisevic
  • 3,377
  • 21
  • 24
3

I have used rinetd for this in the past with great success.

rinetd is a very small, stable, and simple program that listens for incoming connections and forwards them, the configuration is really simple

# bindadress    bindport  connectaddress  connectport
1.2.3.4         80        4.3.2.1         80
1.2.3.4         443       4.3.2.1         443

There is also a program called "stone" that can do the same: Example... http forward from the gateway to an internal machine (1.2.3.4):

$ stone 1.2.3.4:80 80 
rkthkr
  • 8,618
  • 28
  • 38
2

An inetd combined with netcat should do the trick. See Forwarding Ports, although xinetd may be a better choice these days.

brian-brazil
  • 3,952
  • 1
  • 22
  • 16
0

You could use some sort of firewall rule? Something in iptables to redirect one port to another?

Amandasaurus
  • 31,471
  • 65
  • 192
  • 253
0

What you are trying to use smells like NAT Port Forwarding to me. One iptables rules and it's done.

Antoine Benkemoun
  • 7,314
  • 3
  • 42
  • 60