0

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?

  • Why do you need routing for that? Actually, when you do ifconfig up on your VM, it automatically adds pseudo route like 192.168.1.0/24 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
0

Networks:

  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.

Machine1:

ip addr add 1.1.1.2/24 dev eth1
ip route add 2.2.2.0/24 via 1.1.1.1 dev eth1 proto static

Machine3:

ip addr add 2.2.2.2/24 dev eth1
ip route add 1.1.1.0/24 via 2.2.2.1 dev eth1 proto static

Machine2 (router):

ip addr add 1.1.1.1/24 dev eth1
ip addr add 2.2.2.1/24 dev eth2

Testing:

ping 2.2.2.2 # machine1
ping 1.1.1.2 # 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.