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 =
M2 =
M3 =

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 via dev eth1

Likewise on M3:

ip route add via 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?

  • Why do you need routing for that? Actually, when you do ifconfig up on your VM, it automatically adds pseudo route like dev eth0 -- no router involved. – myaut Jun 3 '15 at 11:36
  • There's an application sitting there on M2 which needs to intercept packets going to and from M1 and M3, and do its stuff. I'm trying to simulate such a setup on VMs. – Srikanth Jun 3 '15 at 12:22
  • 2
    Than create two bridges/virtual switches, put M1 and one iface of M2 to first and second iface of M2 along with M3 to another switch, create two subnetworks and make M2 real router. – myaut Jun 3 '15 at 12:25


  1. Create a single-server private network on Xen.
  2. Add it machine1 and machine3, one each.
  3. Add two of them created at step 1 to machine2.


ip addr add dev eth1
ip route add via dev eth1 proto static


ip addr add dev eth1
ip route add via dev eth1 proto static

Machine2 (router):

ip addr add dev eth1
ip addr add dev eth2


ping # machine1
ping # machine3

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.