1

Say I have a machine A acting as a router with two NICs and the following IP addresses:

eth0: 192.168.1.1 (LAN)
eth1: 10.0.0.1 (WAN)

And I have another machine B on IP address 10.0.0.2 that I want to be able to temporarily reach into a device on machine A's subnet with IP address 192.168.1.10.

This would need to handle multiple connections over the same port (like an HTTP session), rather than just a one off. I know of how to do this with SSH but I was wondering if there was a simpler alternative because in this scenario I'm already logged into machine A.

This is the SSH template I use for a similar scenario, when I'm not already logged in:

ssh -R 0:lanhost:lanport username@wanhost

The closest I've been able to get is this with netcat:

nc -s 10.0.0.1 -l -p 50000 -e /tmp/srv.sh

/tmp/srv.sh:

#!/bin/sh
nc 192.168.1.10 80

But that only handles a single connection and creating the shell script is clunky.

NOTE: I'd rather not mess with the IP tables of machine A if possible.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.