Linux – Route all internet traffic through SSH tunnel

amazon ec2linuxsshtunneling

I currently have set up an Amazon EC2 Virtual Private Cloud. Because of IP limitations I can't provide all the instances in the VPC an elastic IP. I have one public facing server and I have a bunch of other private servers in the same VPC.

Please refer to diagram
http://i.imgur.com/9qvNfz0.png

My objective is to have a connection to the internet on 10.0.0.2 via 10.0.0.1 to run some basic commands like wget, ping and apt-get commands. What kind of SSH command would I have to run? I have done quite a bit of searching on the net and I haven't found any examples for my case. Either that or I do not understand them.

Any help would be much appreciated. Thanks

Best Answer

you shouldnt need to use ssh for that. but you could do the following:

  1. enable routing on the internet facing machine via the /proc/sys/net/ipv4/ip_forwarding flag.
  2. enable masquerading on it's iptables
  3. set the internal ip of the internet facing machine to be the default gateway for the others.

That way the machines which dont have public ips will simply use the internet facing one as a router.