<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Hey Bruce,<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thanks for the detailed and beautiful answer.<o:p></o:p></p><p class=MsoNormal>I am actually trying to understand what ipvs gives and to compare it to nftables.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>We need a setup structure which will make it more real.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>I am trying to think about a setup Sketch:<o:p></o:p></p><p class=MsoNormal>3+ Proxies<o:p></o:p></p><p class=MsoNormal>2 LB<o:p></o:p></p><p class=MsoNormal>1 Edge Router VIP(maybe more actual routers)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Networks:<o:p></o:p></p><p class=MsoNormal>PX Internal net: 192.168.100.0/24<o:p></o:p></p><p class=MsoNormal>Wan Edge Routers net: 192.168.200.0/24<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>R1:<o:p></o:p></p><p class=MsoNormal>WAN VIP: 192.168.200.200/24<o:p></o:p></p><p class=MsoNormal>LAN VIP: 192.168.100.254/24<o:p></o:p></p><p class=MsoNormal>Static route toward 192.168.101.100 via 192.168.200.200<o:p></o:p></p><p class=MsoNormal>(Another option would be using FRR for ECMP and ACTIVE/ACTIVE LB)<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Proxies VIP: 192.168.101.100/32<o:p></o:p></p><p class=MsoNormal>PX1 IP: 192.168.100.101/24 GW 192.168.100.254<o:p></o:p></p><p class=MsoNormal>PX2 IP: 192.168.100.102/24 GW 192.168.100.254<o:p></o:p></p><p class=MsoNormal>PX3 IP: 192.168.100.103/24 GW 192.168.100.254<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>LBs VIP: 192.168.200.200/24<o:p></o:p></p><p class=MsoNormal>LB 1 IP: 192.168.200.201/24<o:p></o:p></p><p class=MsoNormal>LB 2 IP: 192.168.200.202/24<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>## Things to consider about the setup:<o:p></o:p></p><p class=MsoNormal>We can use either FWMARK based LB or mac replacement.<o:p></o:p></p><p class=MsoNormal>It is possible to avoid arp issues with either tunnels or VIP assignment to interfaces.<o:p></o:p></p><p class=MsoNormal>There are couple tunneling options such as GENEVE\GUE\FUE\GRE\IPIP which can be used with IPVS.<o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Thoughts? <o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>----<o:p></o:p></p><p class=MsoNormal>Eliezer Croitoru<o:p></o:p></p><p class=MsoNormal>Tech Support<o:p></o:p></p><p class=MsoNormal>Mobile: +972-5-28704261<o:p></o:p></p><p class=MsoNormal>Email: <a href="mailto:ngtech1ltd@gmail.com">ngtech1ltd@gmail.com</a><o:p></o:p></p><p class=MsoNormal><o:p> </o:p></p><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b>From:</b> Bruce Rosenberg <bruce.rosenberg.au@gmail.com> <br><b>Sent:</b> Thursday, August 27, 2020 7:35 AM<br><b>To:</b> Eliezer Croitor <ngtech1ltd@gmail.com><br><b>Cc:</b> squid-users@lists.squid-cache.org<br><b>Subject:</b> Re: [squid-users] IPVS/LVS load balancing Squid servers, anyone did it?<o:p></o:p></p></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>Hi Eliezer,<o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>We are running a couple of Squid proxies (the real servers) in front of a pair of LVS servers with keepalived and it works flawlessly.<o:p></o:p></p></div><div><p class=MsoNormal>The 2 x Squid proxies are active / active and the LVS servers are active / passive.<o:p></o:p></p></div><div><p class=MsoNormal>If a Squid proxy dies the remaining proxy takes all the traffic.<o:p></o:p></p></div><div><p class=MsoNormal>If the active LVS server dies, keepalived running on the backup LVS (via VRRP) moves the VIP to itself and it takes all the traffic, so the only difference between the two is one has a higher priority so it gets the VIP first.<o:p></o:p></p></div><div><p class=MsoNormal>I have included some sanitised snippets from a keepalived.conf file that should help you.<o:p></o:p></p></div><div><p class=MsoNormal>You could easily scale this out if you need more than 2 Squid proxies.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>The config I provided is for LVS/DR (Direct Route) mode.<o:p></o:p></p></div><div><p class=MsoNormal>This method rewrites the MAC address of forwarded packets to that of one of the real servers and is the most scalable way to run LVS.<o:p></o:p></p></div><div><p class=MsoNormal>It does require the LVS and real servers be on the same L2 network.<o:p></o:p></p></div><div><p class=MsoNormal>If that is not possible then consider LVS/TUN mode or LVS/NAT mode.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>As LVS/DR rewrites the MAC address, it requires each real server to have the VIP address plumbed on an interface and also requires the real servers to ignore ARP requests for the VIP address as the only device that should respond to ARP requests for the VIP is the active LVS server.<o:p></o:p></p></div><div><p class=MsoNormal>We do this by configuring the VIP on the loopback interface on each real but there are other methods as well such as dropping the ARP responses using arptables, iptables or firewalld.<o:p></o:p></p></div><div><p class=MsoNormal>I think back in the kernel 2.4 and 2.6 days people used the noarp kernel module which could be configured to ignore ARP requests for a particular IP address but you don't really need this anymore.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>More info on the loopback arp blocking method - <a href="https://www.loadbalancer.org/blog/layer-4-direct-routing-lvs-dr-and-layer-4-tun-lvs-tun-in-aws/" target="_blank">https://www.loadbalancer.org/blog/layer-4-direct-routing-lvs-dr-and-layer-4-tun-lvs-tun-in-aws/</a><o:p></o:p></p></div><div><p class=MsoNormal>More info on firewall type arp blocking methods - <a href="https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/load_balancer_administration/s1-lvs-direct-vsa" target="_blank">https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/load_balancer_administration/s1-lvs-direct-vsa</a><o:p></o:p></p></div><div><p class=MsoNormal>More info about LVS/DR - <a href="http://kb.linuxvirtualserver.org/wiki/LVS/DR" target="_blank">http://kb.linuxvirtualserver.org/wiki/LVS/DR</a><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>If you are using a RPM based distro then to set up the LVS servers you only need the <span style='font-size:10.5pt;color:#2D2D2D'>ipvsadm and keepalived packages.</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;color:#2D2D2D'>Install squid on the reals and configure the VIP on each and disable ARP.</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;color:#2D2D2D'>Then build the keepalived.conf on both LVS servers and restart keepalived.</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;color:#2D2D2D'>The priority configuration stanza in the vrrp_instance section determines the primary VRRP node (LVS server) for that virtual router instance.</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;color:#2D2D2D'>The secondary LVS server needs a lower priority compared to the primary.</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;color:#2D2D2D'>You can configure one as the MASTER and the other as the BACKUP but our guys make them both BACKUP and let the priority sort the election of the primary out.</span><o:p></o:p></p></div><div><p class=MsoNormal><span style='font-size:10.5pt;color:#2D2D2D'>I think this might be to solve a problem of bringing up a BACKUP without a MASTER but I can't confirm that.</span><o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Good luck.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>$ cat /etc/keepalived/keepalived.conf<br><br>global_defs {<br><br> notification_email {<br> # <a href="mailto:rootmail@example.com">rootmail@example.com</a><br> }<br> notification_email_from <a href="mailto:keepalive-daemon@lvs01.example.com">keepalive-daemon@lvs01.example.com</a><br> smtp_server 10.1.2.3 # <a href="http://mail.example.com">mail.example.com</a><br> smtp_connect_timeout 30<br> lvs_id <a href="http://lvs01.example.com">lvs01.example.com</a> # Name to mention in email.<br>}<br><br>vrrp_instance LVS_example {<br><br> state BACKUP<br> priority 150<br> interface eth0<br> lvs_sync_daemon_interface eth0<br> virtual_router_id 5<br> preempt_delay 20<br><br> virtual_ipaddress_excluded {<br> <br> 10.10.10.10 # Squid proxy<br> }<br><br> notify_master "some command to log or send an alert"<br> notify_backup "some command to log or send an alert"<br> notify_fault "some command to log or send an alert"<br>}<br><br><br># SQUID Proxy<br>virtual_server 10.10.10.10 3128 { <br><br> delay_loop 5<br> lb_algo wrr<br> lb_kind DR<br> protocol TCP<br><br> real_server 10.10.10.11 3128 { # <a href="http://proxy01.example.com">proxy01.example.com</a><br> weight 1<br> inhibit_on_failure 1<br> TCP_CHECK {<br> connect_port 3128<br> connect_timeout 5<br> }<br> }<br><br> real_server 10.10.10.12 3128 { # <a href="http://proxy02.example.com">proxy02.example.com</a><br> weight 1<br> inhibit_on_failure 1<br> TCP_CHECK {<br> connect_port 3128<br> connect_timeout 5<br> }<br> }<br>}<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal>On Thu, Aug 27, 2020 at 8:24 AM Eliezer Croitor <<a href="mailto:ngtech1ltd@gmail.com" target="_blank">ngtech1ltd@gmail.com</a>> wrote:<o:p></o:p></p></div><blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt'><div><div><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Hey All,<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>I am reading about LB and tried to find an up-to-date example or tutorial specific to squid with no luck.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>I have seen: <a href="http://kb.linuxvirtualserver.org/wiki/Building_Web_Cache_Cluster_using_LVS" target="_blank">http://kb.linuxvirtualserver.org/wiki/Building_Web_Cache_Cluster_using_LVS</a><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Which makes sense and also is similar or kind of identical to WCCP with gre.<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Anyone knows about a working Squid setup with IPVS/LVS?<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Thanks,<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Eliezer<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>----<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Eliezer Croitoru<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Tech Support<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Mobile: +972-5-28704261<o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'>Email: <a href="mailto:ngtech1ltd@gmail.com" target="_blank">ngtech1ltd@gmail.com</a><o:p></o:p></p><p class=MsoNormal style='mso-margin-top-alt:auto;mso-margin-bottom-alt:auto'> <o:p></o:p></p></div></div><p class=MsoNormal>_______________________________________________<br>squid-users mailing list<br><a href="mailto:squid-users@lists.squid-cache.org" target="_blank">squid-users@lists.squid-cache.org</a><br><a href="http://lists.squid-cache.org/listinfo/squid-users" target="_blank">http://lists.squid-cache.org/listinfo/squid-users</a><o:p></o:p></p></blockquote></div></div></body></html>