[lvs-users] IPVS NAT source IP selection

Julian Anastasov ja at ssi.bg
Sat Jan 5 15:51:10 GMT 2019


On Thu, 27 Sep 2018, Leandro R wrote:

> Hi there,
> I have a simple L4 Director setup with multiple real network interface
> (eth0, eht1, and eth2) my real servers only have access to the director
> through its eth1 <IP> interface.
> When I create a simple rule (L4 NAT (masquerading) pointing to all my
> reals) it does the NAT using the eth0 as the source ip to the real. Now my
> questions:
> How does the ipvs choose which ip / network interface to be its SNAT to the
> reals? (the first one eth0)

	For NAT method: only based on the real server IP.

> Can I induce/setup it to pick a specific one? (like eth1)

	Probably, you should have host route in director, one per real 

ip route add RIP1/32 dev eth1 src IP_X

	Note that IPVS sends packets to real server by preserving the
client IP in the IP saddr. If you later do MASQ, then check the code in
nf_nat_masquerade_ipv4(): it selects local IP from the output interface
that is already selected by IPVS. But may be you can do SNAT as well,
in this case you can specify the desired saddr.


Julian Anastasov <ja at ssi.bg>

More information about the lvs-users mailing list