Re: [lvs-users] load balancing queries to localhost:port?

To: Tomasz Chmielewski <mangoo@xxxxxxxx>
Subject: Re: [lvs-users] load balancing queries to localhost:port?
Cc: " users mailing list." <lvs-users@xxxxxxxxxxxxxxxxxxxxxx>
From: Simon Horman <horms@xxxxxxxxxxxx>
Date: Mon, 20 Sep 2010 14:49:21 +0900
On Sun, Sep 19, 2010 at 04:59:44PM +0200, Tomasz Chmielewski wrote:
> Is it possible to load balance queries to localhost?
> Say, I have two servers - I'd like them to be both directors and realservers.
> Application connecting to localhost:1111 should be connected to either one or 
> the other server. Despite many tries, I'm not able to achieve this.
> I had partial success with LVS-NAT rules:
> -A -t -s lc
> -a -t -r -m -w 1 # same server as localhost, 
> works
> -a -t -r -m -w 1 # remote server
> Where the remote realserver receives the packet:
> 16:54:18.078365 IP (tos 0x10, ttl 64, id 52411, offset 0, flags [DF], proto 
> TCP (6), length 60) > S, cksum 0xc03d 
> (correct), 1282046761:1282046761(0) win 32792 <mss 16396,sackOK,timestamp 
> 178066 0,nop,wscale 7>
> But I guess it's confused about what to do with it, since it appears to come 
> from

Yes, I think that is is confused because it comes from

You need to make sure that the source address of that the client
(application) uses is one that the real-server can route to.
Typically the primary IP address on eth0.

If you can't set the application up to use a different source address
directly, then you may be better off to use a 10.0.0.x address as
the VIP (instead of

Alternatively you may have some luck using the dnat feature
which will be introduced in 2.6.35.

Please read the documentation before posting - it's available at: mailing list - lvs-users@xxxxxxxxxxxxxxxxxxxxxx
Send requests to lvs-users-request@xxxxxxxxxxxxxxxxxxxxxx
or go to

<Prev in Thread] Current Thread [Next in Thread>