Last active
October 19, 2022 20:56
-
-
Save angely-dev/e86e319788c31a7207a9ebf924cd6a92 to your computer and use it in GitHub Desktop.
Load balancing between LNS (L2TP), using FreeRADIUS and a custom module (UNLANG).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# /etc/freeradius/policy.d/lns_load_balancing | |
# | |
# Random load balancing between two LNS. | |
# Note: the same LNS can be returned twice in a row. | |
# If it's an issue, feel free to use a non-binary rand interval (e.g., rand:9 instead of rand:2) | |
# and adapt below conditions (e.g., 0..4 is first LNS, 5..9 is second LNS). | |
# | |
lns_load_balancing { | |
# | |
# Get random number: | |
# 0 => keep first LNS only | |
# 1 => keep second LNS only | |
# | |
if ("%{rand:2}" == "0") { | |
update reply { | |
&Tunnel-Server-Endpoint:1 !* ANY | |
&Tunnel-Assignment-ID:1 !* ANY | |
&Tunnel-Password:1 !* ANY | |
&Tunnel-Client-Auth-ID:1 !* ANY | |
&Tunnel-Type:1 !* ANY | |
&Tunnel-Medium-Type:1 !* ANY | |
&Tunnel-Preference:1 !* ANY | |
} | |
} else { | |
update reply { | |
&Tunnel-Server-Endpoint:0 !* ANY | |
&Tunnel-Assignment-ID:0 !* ANY | |
&Tunnel-Password:0 !* ANY | |
&Tunnel-Client-Auth-ID:0 !* ANY | |
&Tunnel-Type:0 !* ANY | |
&Tunnel-Medium-Type:0 !* ANY | |
&Tunnel-Preference:0 !* ANY | |
} | |
} | |
updated | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Below an example of the module execution. Tested on FreeRADIUS version 3.0.21.
FreeRADIUS server log: