0

I have three servers in my project. Server A has a public IP address (11.11.11.11/24), Server B has both public and private addresses (22.22.22.22/24, 10.10.10.22/24) and Server C only has a private IP address (10.10.10.33/24).

You can see that Server B and Server C are in the same private LAN.

enter image description here

Now my requirement is for Server A to connect to Server C. It would then run some commands via SSH. Is there any way to do this? Do I need any static routes or a proxy?

1

You can use ProxyJump/-J commandline option (if your openssh supports it):

ssh -J 22.22.22.22 10.10.10.30

or setup a DNAT on 22.22.22.22:

sysctl net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -d 22.22.22.22 -p tcp -m tcp --dport 2222 -j DNAT --to-destination 10.10.10.30:22

and connect to specific port:

ssh -p 2222 22.22.22.22
1

In addition to ssh -J PROXY, as was answered by @Tomek, you can use ProxyJump and ProxyCommand in your ~/.ssh/config file to simplify connections on the command line. This has been covered elsewhere, including this post

-1

I was having the same problem refer to this link

In simple terms do:

Net forwarding by net forwarding by uncommenting this line net.ipv4.ip_forward=1

Try ping the A system from B system and vice-versa. It will work

  • This is not the same problem at all. Private IPs are not Internet-routable. Even if routing were enabled on host B, it would not suffice. – Daniel B Apr 29 at 9:36
  • Ok @DanielB it working in my case. Sorry. – jkp Apr 29 at 10:10

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.