Friday, November 19, 2021

Multi gateways loadbalancing

I'm trying to loadbalance trafic (all ports) between multiple gateways (VMs) to test a product from my entreprise.

See the following schema : ```

 ---> GW1 --- / \ 

<client1> ---> <load balancer> --- ---> <web server> \ / ---> GW2 --- ``` Explanations :

I want the client1 trafic to go randomly (round robin) through GW1 or GW2. In this example, I only have 2 gateways (GW1 and GW2) in this example, but in reality, I plan to have many more of them. Same for the clients. What I wall "gateways" (GW1 and GW2) are VMs. So I don't want to loadbalance trafic between network interfaces, but between multiple IP addresses.

I saw many docs / topics online about "standard" loadbalancing; but there is a very little amount of docs about what I'm trying to do (looks like it's called "multi WAN" or "multipath routing").

I saw things like :

``` table ip nat { chain postrouting { type nat hook postrouting priority srcnat; policy accept; oif "eth0" snat to xxx }

chain prerouting { type nat hook prerouting priority dstnat; policy accept; #dnat to numgen inc mod 2 map { 0 : <gw1>, 1 : <gw2> } } 

} ```

But that's not what I want to achieve and this config (located on the machine I called <load balancer> on the schema) is changing the flow destination so that they are trying to connect on GW1 or GW2. But I want to route the trafic through GW1 or GW2.

I also saw things like iptables / nftables marking the flows so that the flows are routed to a specific gateway.

Vyos looks interesting about what I plan to do but I didn't tested it yet https://docs.vyos.io/en/latest/configuration/loadbalancing/index.html

There are also ECMP and a project called nftlb...

I want to : - Loadbalance through multiple gateways any type of trafic (ICMP / UDP / TCP / etc) - Be able to change the configuration easily (Vyos API looks interesting...) whithout restarting everytime - Be able to scale easily (many "gateways")

Can I get recommendations about what I want to do ? In your opinion, what is the best solution ? Any tips ?

Thanks ! Have a good day, bois !



No comments:

Post a Comment