FortiGate
FortiGate Next Generation Firewall utilizes purpose-built security processors and threat intelligence security services from FortiGuard labs to deliver top-rated protection and high performance, including encrypted traffic.
zromano
Staff
Staff
Article Id 359852
Description This article describes the effect of the weight attribute on static routes when ECMP is used.
Scope FortiGate.
Solution
It is possible to configure weights on static routes and interfaces.
The weight is only take into consideration in some ECMP (equal cost multi-path) load-balancing method and the behavior is different if SD-WAN has been enabled.
 
How to select load-balancing algorithm
If SD-WAN is disabled, ECMP method is selected with the following commands:
 
config system settings
    set v4-ecmp-mode <source-ip-based | source-dest-ip-based | weight-based | usage-based>
end
 
If SD-WAN is enabled, the command above will not be available, and the load-balancing method is selected with the following commands:
 
config system sdwan
    set load-balance-mode <source-ip-based | source-dest-ip-based | weight-based | usage-based | measured-volume-based>
end
 
Default algorithm is source-ip-based. Weights are only taken into consideration with the weight-based algorithm or measured-volume-based (available only with SD-WAN).
 
How to configure weights:
If SD-WAN is disabled, weights can be configured either on the interface, or in the static routes. This can be configured only from the CLI.
On the interface level:
 
config system interface
    edit <interface>
        set weight <0-255>
    next
end
 
On the static route level:
 
config router static
    edit <static-route-ID>
        set weight <0-255>
    next
end
 
If the weight is configured in the static routes, it will take precedence over the interface weight.
 
If SD-WAN is enabled, and weight-based algorithm is selected, weight has to be configured in the SD-WAN member instead of the interface. 
 
config system sdwan
    config member
        edit <interface>
            set weight <1-255>
        next
    end
end
 
If a static route is configured with an SD-WAN zone as a destination interface with a weight-based load-balancing algorithm, weight configured on the interface will not be considered.
If a static route is configured with the specific destination interface (not the SD-WAN zone), then an interface or static route weight will be used.
 
How the traffic is load balanced:
It is possible to check the assigned weight from the routing table, and the following output is useful to understand the behavior:
 
FGT # get router info routing-table all
[output omitted]
Routing table for VRF=0
S*      0.0.0.0/0 [10/0] via 10.254.0.19, port1, [10/80]
                  [10/0] via 10.255.0.19, port2, [10/20]
  
It is important that all interfaces on which traffic is being load balanced have the same admin distance (interfaces with higher distance will not be included in the routing table) and priority (otherwise routes with the lowest priority will be used).
Looking at the routing table above, both routes have the same admin distance (10) and priority (10). The FortiGate will load balance traffic on port1 and port2.
The last number in each static route line indicates the weight. FortiGate uses the weights to compute the percentage of traffic to send to each interface.
In the example above, two static routes have been configured one with weight 80 (on port1), and the other with weight 20 (port2).
This adds up to 100, but the percentages are calculated with the following formula, so configuring weights 80 on port1 and 20 on port1, or 4 and 1 respectively, would achieve the same results.
 
(Percentage of sessions) = (member's weight) / (sum of all weights).
 
With the weight-based method (both with or without SD-WAN), FortiGate will try to load-balance sessions more on interfaces that have a higher weight. Traffic for the same session will be kept on the same outgoing interface.
Note: FortiGate will not consider the amounts of bytes flowing through the interface with the weight-based algorithm, only number of sessions.
 
In SD-WAN, if volume-based is selected, FortiGate will also consider the amount of traffic, and will try to distribute sessions according to number of packets passing on each interface.
 
Note: Since the number of sessions and traffic can vary quite quickly, the percentage of sessions/traffic per interface will never completely match the theoretical ones.
Contributors