-1

I have a nonstandard network of VMs that are causing routing headaches. Each VM is homed on on three different subnets (192.168.1.0/24 through 192.168.3.0/24), and each VM can connect to every other VM --- but only over a single subnet. For example: VM1 (192.168.*.1) can connect to VM2 (192.168.*.2) only over subnet 2 (can ping 192.168.2.2), while VM3 can connect to VM2 only over subnet 3 (can ping 192.168.3.2).

I'd like to write some iptables rules (or similar) on VM1 such that I can have a "fake route" for local traffic to 192.168.1.2 which actually goes to 192.168.2.2. Any thoughts on how to do this?

Mae Milano
  • 714
  • 4
  • 14

1 Answers1

0

Oh! I can just ignore the subnet information and directly add a route via the correct ethernet device. Neat!

For example, if ens2 has a route to 192.168.2.0/24, I can just run ip route add 192.168.1.2/32 dev ens2 and that will work correctly, assuming the device at the other end of ens2 actually does have 192.168.1.2 as one of its addresses.

Mae Milano
  • 714
  • 4
  • 14