From owner-freebsd-questions@FreeBSD.ORG Mon Jul 11 17:44:09 2011 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1A52F106566C for ; Mon, 11 Jul 2011 17:44:09 +0000 (UTC) (envelope-from cswiger@mac.com) Received: from asmtpout024.mac.com (asmtpout024.mac.com [17.148.16.99]) by mx1.freebsd.org (Postfix) with ESMTP id 02EAF8FC0A for ; Mon, 11 Jul 2011 17:44:08 +0000 (UTC) MIME-version: 1.0 Content-transfer-encoding: 7BIT Content-type: text/plain; CHARSET=US-ASCII Received: from cswiger1.apple.com ([17.209.4.71]) by asmtp024.mac.com (Oracle Communications Messaging Exchange Server 7u4-18.01 64bit (built Jul 15 2010)) with ESMTPSA id <0LO6009WRJX4FU70@asmtp024.mac.com> for freebsd-questions@freebsd.org; Mon, 11 Jul 2011 10:43:52 -0700 (PDT) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:5.4.6813,1.0.211,0.0.0000 definitions=2011-07-11_03:2011-07-11, 2011-07-11, 1970-01-01 signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 ipscore=0 suspectscore=0 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx engine=6.0.2-1012030000 definitions=main-1107110147 From: Chuck Swiger In-reply-to: <1310402991.9928.YahooMailClassic@web160114.mail.bf1.yahoo.com> Date: Mon, 11 Jul 2011 10:43:51 -0700 Message-id: References: <1310402991.9928.YahooMailClassic@web160114.mail.bf1.yahoo.com> To: Unga X-Mailer: Apple Mail (2.1084) Cc: freebsd-questions@freebsd.org Subject: Re: Transparent load balancing X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Jul 2011 17:44:09 -0000 On Jul 11, 2011, at 9:49 AM, Unga wrote: > I need to implement a transparent load balancing daemon in C. > > That is, the daemon accept a TCP connection, get more info from the client, and forward the communication transparently to another server to handle it. > > How this could be implemented on FreeBSD? What basic primitives I should study more? You can use redirect_address in natd to accomplish simple round-robin load-balancing, ie: -redirect_address localIP[,localIP[,...]] publicIP These forms of -redirect_port and -redirect_address are used to transparently offload network load on a single server and distribute the load across a pool of servers. This function is known as LSNAT (RFC 2391). For example, the argument tcp www1:http,www2:http,www3:http www:http means that incoming HTTP requests for host www will be trans- parently redirected to one of the www1, www2 or www3, where a host is selected simply on a round-robin basis, without regard to load on the net. Regards, -- -Chuck