I've a Citrix Xenserver where I'm running VMs. I have three VMs there, and they have 2 NICs each: eth0
is my company LAN which I'm using for management, and eth1
is a "single-server private network" on all three VMs. The management interface is just for my SSH sessions.
The IPs assigned to my VMs are:
M1 = 192.168.0.1/24
M2 = 192.168.0.2/24
M3 = 192.168.0.3/24
On M2, I've got IP forwarding enabled:
echo 1 > /proc/sys/net/ipv4/ip_forward
To route the traffic via M2 from M1 to M3:
ip route add 192.168.0.3 via 192.168.0.2 dev eth1
Likewise on M3:
ip route add 192.168.0.1 via 192.168.0.2 dev eth1
But when I traceroute or send traffic from M1 to M3 (or vice versa), it seems to be going straight to the destination instead of going through M2. Is it because they are on the same subnet? If they are on the same subnet, what should be done on my Linux machine to achieve this routing?
ifconfig up
on your VM, it automatically adds pseudo route like192.168.1.0/24 dev eth0
-- no router involved.