Monday, June 4, 2018

Route Traffic between two subnets separated by another network

Please consider the following image: https://i.imgur.com/D0db4cn.png

  • I have four hosts; A, B, X, and Y.

  • I have three networks; 192.168.1.0/24, 192.168.2.0/24, and 172.16.1.0/24. (hosts A and B have separate connections to the internet via their eth0)

  • On Host-A I have this route: ip route add 192.168.2.0/24 via 172.16.1.2

  • On Host-B I have this route: ip route add 192.168.1.0/24 via 172.16.1.1

I want to be able to ssh to Host-Y from Host-X (and vice versa). I also want to be able to reach the internet from Host-X via Host-A, and from Host-Y via Host-B.

What would be the iptables rules to allow for such a network configuration? Do I need any extra routes?



No comments:

Post a Comment