0

I have a host local-dev that maps to a VM's IP address.

Theres an AWS EC2 instance running a webserver, to which I want to enable ssh forwarding on a certain port i.e. I want it to forward any requests made to local-dev:85 to the ec2 instance.

local-dev is also configured with dnsmasq to support subdomains, and these subdomains must work and be forwarded too.

Whats the best way of doing this? I've tried a bunch of ssh -L type commands, but they all fail for one reason or another. One of the problems is that the ssh happens for the ec2-user, and I presume it must happen as root.

1 Answer 1

0

well there are two options:

  1. do it with iptables on the local-dev instance

    iptables -A PREROUTING -s 0.0.0.0/0 -d ip-of-local-dev/32 -p tcp -m tcp --dport 85 -j DNAT --to-destination ip-of-ec2-instance:target_port

or

  1. you can do it with SSH tunnel. The port for incomming on the local-dev server needs to be above 1024 when you don´t want to do it as root

    -L 0.0.0.0:1085:ip-of-ec2-instance:target_port

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .