diff options
author | Nicolas Fort <nicolasfort1988@gmail.com> | 2023-08-08 08:19:36 -0300 |
---|---|---|
committer | Nicolas Fort <nicolasfort1988@gmail.com> | 2023-08-08 08:23:33 -0300 |
commit | d1d64ac44d606ecdb35ff29161121c519bce48da (patch) | |
tree | 13aaf788ae8c14d2ac3060cca9bdd1754af3147a /docs/configuration | |
parent | 5e4eadf0a118d8ca5d29ad39b0cef9ac2491b89c (diff) | |
download | vyos-documentation-d1d64ac44d606ecdb35ff29161121c519bce48da.tar.gz vyos-documentation-d1d64ac44d606ecdb35ff29161121c519bce48da.zip |
T5014: add NAT Load Balance commands and configuration example.
Diffstat (limited to 'docs/configuration')
-rw-r--r-- | docs/configuration/nat/nat44.rst | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/docs/configuration/nat/nat44.rst b/docs/configuration/nat/nat44.rst index 3a73d444..9aeb581e 100644 --- a/docs/configuration/nat/nat44.rst +++ b/docs/configuration/nat/nat44.rst @@ -283,6 +283,32 @@ Example of redirection: set nat destination rule 10 translation redirect port 22 +NAT Load Balance +---------------- + +Advanced configuration can be used in order to apply source or destination NAT, +and within a single rule, be able to define multiple translated addresses, +so NAT balances the translations among them. + +NAT Load Balance uses an algorithm that generates a hash and based on it, then +it applies corresponding translation. This hash can be generated randomly, or +can use data from the ip header: source-address, destination-address, +source-port and/or destination-port. By default, it will generate the hash +randomly. + +When defining the translated address, called ``backends``, a ``weight`` must +be configured. This lets the user define load balance distribution according +to their needs. Them sum of all the weights defined for the backends should +be equal to 100. In oder words, the weight defined for the backend is the +percentage of the connections that will receive such backend. + +.. cfgcmd:: set nat [source | destination] rule <rule> load-balance hash + [source-address | destination-address | source-port | destination-port + | random] +.. cfgcmd:: set nat [source | destination] rule <rule> load-balance backend + <x.x.x.x> weight <1-100> + + Configuration Examples ====================== @@ -602,6 +628,40 @@ provide access to their internal resources, and require that a connecting organisation translate all traffic to the service provider network to a source address provided by the ASP. +Load Balance +------------ +Here we provide two examples on how to apply NAT Load Balance. + +First scenario: apply destination NAT for all HTTP traffic comming through +interface eth0, and user 4 backends. First backend should received 30% of +the request, second backend should get 20%, third 15% and the fourth 35% +We will use source and destination address for hash generation. + +.. code-block:: none + + set nat destination rule 10 inbound-interface eth0 + set nat destination rule 10 protocol tcp + set nat destination rule 10 destination port 80 + set nat destination rule 10 load-balance hash source-address + set nat destination rule 10 load-balance hash destination-address + set nat destination rule 10 laod-balance backend 198.51.100.101 weight 30 + set nat destination rule 10 laod-balance backend 198.51.100.102 weight 20 + set nat destination rule 10 laod-balance backend 198.51.100.103 weight 15 + set nat destination rule 10 laod-balance backend 198.51.100.104 weight 35 + +Second scenario: apply source NAT for all outgoing connections from +LAN 10.0.0.0/8, using 3 public addresses and equal distribution. +We will generate the hash randomly. + +.. code-block:: none + + set nat source rule 10 outbound-interface eth0 + set nat source rule 10 source address 10.0.0.0/8 + set nat source rule 10 load-balance hash random + set nat source rule 10 load-balance backend 192.0.2.251 weight 33 + set nat source rule 10 load-balance backend 192.0.2.252 weight 33 + set nat source rule 10 load-balance backend 192.0.2.253 weight 34 + Example Network ^^^^^^^^^^^^^^^ |