diff options
author | Christian Breunig <christian@breunig.cc> | 2024-03-04 14:50:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-04 14:50:16 +0100 |
commit | d9047062977f029322d1e91002a748b2d17c5825 (patch) | |
tree | 84213392cf052ed45997ba5475606f75e51dbd66 /python/vyos | |
parent | 70cf2388a184eacc6fb52d9edfb1c930de3bbb6a (diff) | |
parent | a7a0c90404d03f7deccb74a46d0fe1f99116907a (diff) | |
download | vyos-1x-d9047062977f029322d1e91002a748b2d17c5825.tar.gz vyos-1x-d9047062977f029322d1e91002a748b2d17c5825.zip |
Merge pull request #3080 from nicolas-fort/T6086
T6086: NAT: fix nat rules when using source-groups and translation address is a network.
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/nat.py | 11 |
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': |