# Layer-4 Load Balancing



## tantra35 (Nov 20, 2010)

Hi

Does FreeBSD have software to support "Layer-4 Load Balancing" like LVS? I found only ipvs, but it doesn't work on FreeBSD 8.0.


----------



## SirDice (Nov 24, 2010)

As I understood it the balancing is done on layer 7, not 4.

Have a look at net/haproxy.


----------



## tantra35 (Nov 24, 2010)

No its l4 router.

http://www.linuxvirtualserver.org/VS-DRouting.html

For example it's allow balance outgoing traffic


----------



## SirDice (Nov 24, 2010)

If you want layer3/4 load balancing have a look at CARP.


----------



## phoenix (Nov 24, 2010)

Or lagg(4), or setfib() combined with ipfw(8) rules.


----------



## Galactic_Dominator (Sep 13, 2012)

Neither lagg, nor carp offer L4 load balancing.  They use L2 and/or L3.


----------



## mamalos (Sep 14, 2012)

Pardon my ignorance: 

Which is the 4th layer in the TCP/IP stack? Because layer 7 filtering refers to OSI layer 7, and as far as I knew (until now) TCP/IP's layer 4 was equivalent to OSI's 7th layer (since IP does not implement all 7 OSI layers). 

Of course I may be totally wrong, but since I see that some of you know, please post a reference to layer 4 filtering in IP networks.


----------



## Galactic_Dominator (Sep 15, 2012)

> Which is the 4th layer in the TCP/IP stack?


TCP(or any other protocol immediately following the layer 3 IP)

 Layer 2 LB is done on the destination MAC
 Layer 3 LB is done on the destination IP
 Layer 4 LB is done on the combination of destination IP address and port.
 Layer 5 LB is done on the combination of destination IP address, port and protocol eg http connection.
 Layer 7 LB is done at the application level eg cookie.

I don't know of any serious modern discussions on alternatives to the OSI model.  It won.  Unless otherwise specified, it should be assumed the default without question.


----------



## mamalos (Sep 17, 2012)

Galactic_Dominator,

do you have a reference (citation) of the layers you're mentioning? Stevens, in "TCP/IP illustrated vol. 1", p.6 shows 4 protocols (but refers to an additional one), which are stacked like this:


 application layer (user process)
 transport layer (TCP/UDP)
 network layer (ICMP/IP/IGMP)
 link layer (ARP/Hardware Interface/ RARP)
 media

Of course, your answer refers to load balancing layers, which might be different than network stack layers, since in network terminology when someone refers to a layer-x program, it usually means that the program is handling information exchanged only from the x-th layer (and not a combination of all preceding protocols).

Nevertheless, I can see your point, so maybe there is no need for an answer in my post.

Thanks for your answers.


----------

