From owner-freebsd-net@FreeBSD.ORG Fri Feb 29 16:41:11 2008 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2C74E106566C for ; Fri, 29 Feb 2008 16:41:11 +0000 (UTC) (envelope-from max@love2party.net) Received: from moutng.kundenserver.de (moutng.kundenserver.de [212.227.126.188]) by mx1.freebsd.org (Postfix) with ESMTP id B217E8FC15 for ; Fri, 29 Feb 2008 16:41:10 +0000 (UTC) (envelope-from max@love2party.net) Received: from vampire.homelinux.org (dslb-088-066-018-180.pools.arcor-ip.net [88.66.18.180]) by mrelayeu.kundenserver.de (node=mrelayeu5) with ESMTP (Nemesis) id 0ML25U-1JV8652gql-0006Wh; Fri, 29 Feb 2008 17:28:33 +0100 Received: (qmail 11319 invoked by uid 80); 29 Feb 2008 16:28:07 -0000 Received: from 192.168.4.151 (SquirrelMail authenticated user mlaier) by router.laiers.local with HTTP; Fri, 29 Feb 2008 17:28:07 +0100 (CET) Message-ID: <55614.192.168.4.151.1204302487.squirrel@router.laiers.local> In-Reply-To: <200802291635.38308.gizmen@blurp.pl> References: <200802291635.38308.gizmen@blurp.pl> Date: Fri, 29 Feb 2008 17:28:07 +0100 (CET) From: "Max Laier" To: "Bartosz Giza" User-Agent: SquirrelMail/1.4.13 MIME-Version: 1.0 Content-Type: text/plain;charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Priority: 3 (Normal) Importance: Normal X-Provags-ID: V01U2FsdGVkX1/lS5uVWc7c9rux8AXAJJxf5fhb3QmLGWDWTBh opxSWBPBUMeHDUjWD68xEP2+CvSFiQq2C2TzzicpXnj0GvF8Mu FeT44byeIyko2bBfJjWkA== Cc: freebsd-net@freebsd.org Subject: Re: redirecting connections based on probability X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Feb 2008 16:41:11 -0000 Am Fr, 29.02.2008, 16:35, schrieb Bartosz Giza: > Hi, > > I have to do such a thing like redirecting connections to port 80 based on > probability. For example i need to redirect 10% requests to my web server > and > other 90% of requests should go to the original location. > > I know that pf has probability feature but there is no probability option > for > rdr rules. I have tryied couple of methods that could work but they didn't > :( > > The problem is that rdr rules works on incoming packets so i can't use > them > dirrectly because i don't want to redirect all packets to different > location. > > Could somebody tell me is such a thing possible in pf ? If yes please > point me > how is that possible. Say you want to share 1/3 -> IP_A and 2/3 -> IP_B (for the sake of brevity): rdr on $ext_if proto tcp from any to any port 80 \ -> { $IP_B, $IP_A, $IP_B } round-robin This also works with random pool selection. src-hash and bitmask are obviously another story. sticky-address might also skew the results, but could be a good idea nontheless. -- /"\ Best regards, | mlaier@freebsd.org \ / Max Laier | ICQ #67774661 X http://pf4freebsd.love2party.net/ | mlaier@EFnet / \ ASCII Ribbon Campaign | Against HTML Mail and News