-1

I want to connect to a locked (cannot be modified and I do not have permissions to log into) windows vm which is hosted in a linux machine. Until now these two machines were communicating via port 2277. However for security reasons, the port 2277 is only accessible via localhost (127.0.0.1).

The original proposed solution was to use ssh-tunneling. However since the hosted windows vm will always stay with the linux machine, so I was thinking something simpler.

This Windows virtual machine has ip 192.168.0.1 and the default gateway is 192.168.0.2. The later is the ip address that my linux machine can see.

After searching the internet I tried

socat TCP4:192.168.0.1:2277,reuseaddr,fork TCP4:127.0.0.1:2277

as well as some other random combinations without success. My understanding is that this failed because for socat to work both sockets must be open. However the first one is not open by default (checked with ss -ltn) as I need to run the windows service first (which it cannot run as it cannot communicate with iphost:2277)

Any ideas on how to proceed?

Mr_Saint
  • 3
  • 1
  • 5

2 Answers2

0

Socat provides the retry=N and forever options to handle situations like this. Thus, try something like this:

socat -d -d TCP4:192.168.0.1:2277,reuseaddr,fork,forever TCP4:127.0.0.1:2277

With the interval=<seconds> option you can specify how long Socat waits after each failed attempt.

dest-unreach
  • 186
  • 1
  • 9
0

It turns out that the command that I wanted was the following

socat tcp-listen:2277,bind=192.168.0.1,fork,reuseaddr tcp:127.0.0.1:2277

The retry=N and forever options could be also useful.

Mr_Saint
  • 3
  • 1
  • 5