summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorNicolas Fort <nicolasfort1988@gmail.com>2024-03-04 11:32:29 +0000
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2024-03-04 13:52:38 +0000
commitce3b57574bb89312ae8be8cbf5e5cd94c5466493 (patch)
tree1956feaa7d539a8923e0faf1a39e2529b2ac4d07 /python
parent7f7495a55b7fd80c51c3b31a06df282e0e47c412 (diff)
downloadvyos-1x-ce3b57574bb89312ae8be8cbf5e5cd94c5466493.tar.gz
vyos-1x-ce3b57574bb89312ae8be8cbf5e5cd94c5466493.zip
T6086: NAT: fix nat rules when using source-groups and translation address is a network.
(cherry picked from commit a7a0c90404d03f7deccb74a46d0fe1f99116907a)
Diffstat (limited to 'python')
-rw-r--r--python/vyos/nat.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/python/vyos/nat.py b/python/vyos/nat.py
index 7215aac88..da2613b16 100644
--- a/python/vyos/nat.py
+++ b/python/vyos/nat.py
@@ -89,11 +89,14 @@ def parse_nat_rule(rule_conf, rule_id, nat_type, ipv6=False):
if addr and is_ip_network(addr):
if not ipv6:
map_addr = dict_search_args(rule_conf, nat_type, 'address')
- if port:
- translation_output.append(f'{ip_prefix} prefix to {ip_prefix} {translation_prefix}addr map {{ {map_addr} : {addr} . {port} }}')
+ if map_addr:
+ if port:
+ translation_output.append(f'{ip_prefix} prefix to {ip_prefix} {translation_prefix}addr map {{ {map_addr} : {addr} . {port} }}')
+ else:
+ translation_output.append(f'{ip_prefix} prefix to {ip_prefix} {translation_prefix}addr map {{ {map_addr} : {addr} }}')
+ ignore_type_addr = True
else:
- translation_output.append(f'{ip_prefix} prefix to {ip_prefix} {translation_prefix}addr map {{ {map_addr} : {addr} }}')
- ignore_type_addr = True
+ translation_output.append(f'prefix to {addr}')
else:
translation_output.append(f'prefix to {addr}')
elif addr == 'masquerade':