I'm just starting with AWS, and have 2 ec2 instances running on a VPC, one with a public and private IP, one with only a private IP.
I can SSH to both (using my key) if I attach an external IP to them.
I can SSH from server 1 to server 2 (if I copy the pem key onto server 1)
Server 2 I want to be private IP only, and server 1 has a public IP and NAT to server 2. I am trying to follow the tutorial here aws shows the private address of server 2 to be 10.0.0.18 (server 1 is 10.0.0.63)
On server 1 I have added..
sudo iptables -t nat -A PREROUTING -p tcp --dport 10235 -j DNAT --to-destination 10.0.0.18:22 if I look at the tables, I can see...
1 DNAT tcp -- anywhere anywhere tcp dpt:10235 to:10.0.0.18:22 And if I look at packets for iptables...
iptables -L -v -t nat Chain PREROUTING (policy ACCEPT 1 packets, 40 bytes) pkts bytes target prot opt in out source destination 10 600 DNAT tcp -- any any anywhere anywhere tcp dpt:10235 to:10.0.0.18:22 I am trying to connect with...
ssh -i mykeyfile.pem -p 10235 user@<server1domain> Whenever I try, I can see the packets increase on server 1, but I never get any response. I have allowed port 10234&5 & 22 on the security group.
Security group shows as..
Custom TCP Rule TCP 10234 - 10240 0.0.0.0/0 ssh -vvv doesn't provide anything useful, as its just hanging saying 'connecting to myhost port 10235.
As mentioned, if I associate a public IP and connect to that, all works, but I can't seem to get it working via NAT ?