From: Christian Parpart Date: Tue, 10 Jul 2007 14:14:26 +0000 Subject: Re: [LARTC] custom routing (two gateways) Message-Id: <200707101614.26556.trapni@gentoo.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="===============0071898794==" List-Id: References: <200707092007.51792.trapni@gentoo.org> In-Reply-To: <200707092007.51792.trapni@gentoo.org> To: lartc@vger.kernel.org --===============0071898794== Content-Type: multipart/signed; boundary="nextPart3374808.38jDiUysVA"; protocol="application/pgp-signature"; micalg=pgp-sha1 Content-Transfer-Encoding: 7bit --nextPart3374808.38jDiUysVA Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On Monday 09 July 2007 21:01:26 Grant Taylor wrote: > On 07/09/07 13:07, Christian Parpart wrote: > > I tried here several approaches, like adding custom routing tables, > > and modifying the tables (including main) either I got no answers > > routed to the FW or no traffic got routed to the LB. > > I think you were on the right path. > > I would set up a custom routing table for traffic associated with the > load balancer to use. This load balancer routing table would use the > load balancer as the default gateway. > > You would then use ip rule(s) to determine which traffic would deviate > from the normal default routing tables and use the load balancer routing > table. This could probably be done based on source port on the web > server, or based on connection / packet marks in IPTables. However you > do it, you will probably need an additional routing table. > > Keep going the direction you were, or perhaps post some of what you did > try and let us take a look at it to see if you were close. I finally found a way, and your hint (select by server port number) finally= =20 helped me to get rid of it :) The following is the script to be executed at bootup to setup the additiona= l=20 routing table. 1 #! /bin/bash 2 # sets up additional routing table for load balancer traffic on a node 3 4=20 # -------------------------------------------------------------------------= =2D------ 5 LB_IP=3D10.10.10.4 # load balancer IP 6 LB_IF=3Deth0 # ethernet interface the load balancer is= =20 talking from/to 7 8 rt_table_name=3Dloadbalancer # LB routing table name 9 rt_table_num=3D200 # LB routing table ID 10 11 fwmark=3D1 # FW mark to use for LB traffic 12 13 service_port=3D8000 # HTTP port for lighttpd on local mashine = that 14 # serves for the load balancer 15 16=20 # -------------------------------------------------------------------------= =2D------ 17 18 # just ensure that we have a routing table called loadbalancer 19 if ! grep -q ${rt_table_name} /etc/iproute2/rt_tables; then 20 echo "${rt_table_num} ${rt_table_name}" >> /etc/iproute2/rt_tables 21 fi 22 23 # add a default route for communication from LB<->this_host 24 ip route flush table ${rt_table_name} 25 ip route add default via ${LB_IP} table ${rt_table_name} dev ${LB_IF} 26 27 # add a selector rule for which packets we want to use the LB routing ta= ble 28 ip rule add fwmark ${fwmark} table ${rt_table_name} 29 30 # finally lets mark all packets that shall be send out to the LB 31 iptables -t mangle -A OUTPUT -p tcp --sport ${service_port} -j=20 MARK --set-mark ${fwmark} 32 # --(doesn't work? why?)-- iptables -t mangle -A INPUT -p tcp --dport=20 ${service_port} -j CONNMARK --set-mark ${fwmark} However, you might see, that I first tried to fwmark all packets by connect= ion=20 matching,=20 using CONNMARK. so that I only need to select all incoming traffic that cam= e=20 from the load balancer=20 as the previous hop and with our service port 8000, to let mark iptables=20 itself all further connection related packets automatically. but this didn't work out, unfortunately, and= I=20 am using the OUTPUT table to match the packets. What is the better approach anyway? Thanks for your help, Christian Parpart. --nextPart3374808.38jDiUysVA Content-Type: application/pgp-signature; name=signature.asc Content-Description: This is a digitally signed message part. -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.4 (GNU/Linux) iD8DBQBGk5RCPpa2GmDVhK0RAvNDAKCLqGvEh3/CNezjP5INUkla5dHPMwCfYWeE cGCt7vHpJ3zDa39hk0P7dZM= =otui -----END PGP SIGNATURE----- --nextPart3374808.38jDiUysVA-- --===============0071898794== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ LARTC mailing list LARTC@mailman.ds9a.nl http://mailman.ds9a.nl/cgi-bin/mailman/listinfo/lartc --===============0071898794==--