0

I have three EC2 instances. I'd like to route all http requests to one machine and all ssh traffic on the standard port to another. The third machine will be used for routing, but only has one interface: eth0. The idea is that the user gets a single endpoint URL for both http and ssh requests. Right now I have to use a subdomain for the ssh box, which makes commands quite long.

Is there a way to set this up with IPTables? I've tried to set this up with a forward rule, but when trying to ssh in via an external network, the connection times out.

1
  • Ho< did the forward rule you tried look? Jun 20, 2011 at 8:04

1 Answer 1

0

Port forwarding is usually done for machines that are hidden behind a firewall and not otherwise directly accessible. In order to work properly, it requires some form of NAT, which by the sounds of it isn't going to be there in your case. That will make such a setup very awkward.

Effectively you would need to make it such that the router is the only public IP address used, and the other two machines, despite having perfectly usable public IP addresses, are logically arranged behind the router. This can be achieved by setting their default gateway to the IP of the router (i.e. all outgoing traffic goes through the router). Then define DNS entries pointing at the router, and set up the router to perform the necessary forwarding of traffic, complete with NAT.

As long as your router isn't configured properly, I would be very careful with setting the default gateway of the other two machines, since as soon as you do that and the router hasn't been configured to forward traffic properly, you'll lose all connection and the only way to get a working connection will be to ssh into the router and then from there ssh into any of the other machines.

You must log in to answer this question.

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