Linux routing - hop server on same subnet

by perfecto25   Last Updated March 14, 2019 20:00 PM - source

Im trying to get a very simple setup to work,

I have 2 AWS ec2 instances (blue),

instance B has a Ipsec VPN into our datacenter and can ping internal IPs of this datacenter, ie server C (192.168.40.21)

enter image description here

I need ec2 A instance to be able to ping and connect to server C by using B as a hop. Both A and B are on same subnet. I tried adding B's IP as a gateway on A,

  [email protected]>  ip route add 192.168.40.0/24 via 172.25.25.200

and also setup firewall rules on B to forward traffic (sysctl ip4 forwarding = 1),

[email protected]>
iptables -A FORWARD -s 0/0 -d 172.25.25.0/24 -j ACCEPT
iptables -A FORWARD -s 172.25.25.0/24 -d 0/0 -j ACCEPT
iptables -t nat -A POSTROUTING -d 0/0 -s 172.25.25.0/24 -j MASQUERADE

But I cannot ping C from A. What am I missing?

All hosts are Centos 7.

Thank you.



Related Questions


How to retain the source IP?

Updated August 15, 2017 09:00 AM


VPN Inter-Client networking?

Updated November 02, 2015 06:00 AM