1

I have the following question:

considering the attached image: Schema

I have a server (RHEL 7) with 3 IP addresses (on the same physical interface):

  • 192.168.10.1 (eth0, server address on network 192.168.10.0/24)
  • 192.168.10.100 (eth0:1, a cluster resource's virtual IP on network 192.168.10.0/24)
  • 192.168.20.100 (eth0:2, a cluster resource's virtual IP on network 192.168.20.0/24)

Since the two cluster resources are on two different networks, I must be sure that, for each client request to one of the resources, the path of the responses remains exactly the same. This means using the two different gateways on the basis on the resources' IP addresses.

Is source policy routing with iproute2 the right way to achieve this?

Thanks in advance,

Riccardo M.
  • 150
  • 1
  • 9
  • You should not have two IPv4 subnets in the same L2 broadcast domain. This will cause all kinds of difficult situations. You should have VLANs which are separate L2 networks and you can avoid the problems. – Tero Kilkanen Feb 24 '17 at 02:45

1 Answers1

3

Right. Basically, it should look like this (from the working system with two ethernet links):

admin@mamba:~$ ip route show table all
default via 192.168.10.254 dev eth1  table admin
192.168.10.0/24 dev eth1  table admin  scope link  src 192.168.10.100
default via 192.168.20.254 dev eth0
192.168.20.0/24 dev eth0  proto kernel  scope link  src 192.168.20.100
192.168.10.0/24 dev eth1  proto kernel  scope link  src 192.168.10.100

admin@mamba:~$ ip rule show
0:      from all lookup local
32764:  from all to 192.168.10.100 lookup admin
32765:  from 192.168.10.100 lookup admin
32766:  from all lookup main
32767:  from all lookup default
Peter Zhabin
  • 2,696
  • 9
  • 10
  • Hi Peter, thanks for your answer. But what in case the network interface is only one (eg: eth0)? I mean, different virtual IPs belonging to different networks on the same NIC (eth0, eth0:1, eth0:2, ...)? Furthermore, in a clustered environment (where resources may switch to other nodes), an virtual IP address bound to interface eth0:4 on Server1 may move to eth0:2 on Server3. How can I handle this in a "dynamic" sort of way? I read that policy-based routing should work fine with virtual interfaces and/or VLAN tagged interfaces, and I'd like to know if it may suit my needs. Thanks :) – Riccardo M. Feb 22 '17 at 19:05
  • Well, eth0:1, eth0:2 etc are in fact virtual interfaces and those do work with ip rule/ip route just like a normal interface would do. Regarding clustering, if your cluster is making a failover its your clustering technology that is responsible for taking the interface down. – Peter Zhabin Feb 22 '17 at 19:45