summaryrefslogtreecommitdiff
path: root/src/conf_mode/nat_cgnat.py
diff options
context:
space:
mode:
authorViacheslav Hletenko <v.gletenko@vyos.io>2024-05-28 13:06:51 +0000
committerViacheslav Hletenko <v.gletenko@vyos.io>2024-05-28 13:06:51 +0000
commit55e02bef4f3aeff5e33cddc79f22b93fc671e491 (patch)
tree149eedc6a3d62eb654050b0f510f99ebc8259174 /src/conf_mode/nat_cgnat.py
parent48e5266e2bca8d1d7a2ee4bacbe0e6628de3fa66 (diff)
downloadvyos-1x-55e02bef4f3aeff5e33cddc79f22b93fc671e491.tar.gz
vyos-1x-55e02bef4f3aeff5e33cddc79f22b93fc671e491.zip
T6411: CGNAT fix sequences for external address ranges
Fix the bug where address external alocation was not rely on sequences of the external IP addresses (if set)
Diffstat (limited to 'src/conf_mode/nat_cgnat.py')
-rwxr-xr-xsrc/conf_mode/nat_cgnat.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/conf_mode/nat_cgnat.py b/src/conf_mode/nat_cgnat.py
index 5ad65de80..957b12c28 100755
--- a/src/conf_mode/nat_cgnat.py
+++ b/src/conf_mode/nat_cgnat.py
@@ -252,7 +252,11 @@ def generate(config):
ext_pool_name: str = rule_config['translation']['pool']
int_pool_name: str = rule_config['source']['pool']
- external_ranges: list = [range for range in config['pool']['external'][ext_pool_name]['range']]
+ # Sort the external ranges by sequence
+ external_ranges: list = sorted(
+ config['pool']['external'][ext_pool_name]['range'],
+ key=lambda r: int(config['pool']['external'][ext_pool_name]['range'][r].get('seq', 999999))
+ )
internal_ranges: list = [range for range in config['pool']['internal'][int_pool_name]['range']]
external_list_hosts_count = []
external_list_hosts = []