diff options
author | Christian Breunig <christian@breunig.cc> | 2023-08-23 20:19:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-23 20:19:45 +0200 |
commit | 7659c452f8d390773e48e5873552bde601e2fbca (patch) | |
tree | 482e10bf507ff9153a80dfab0b56400c8e9a66bf /python | |
parent | b1886e35e5166034f60541cb4a1020c000627b8c (diff) | |
parent | f0ae034faa74a90ee3c98d31bfd8df2ae0513c7f (diff) | |
download | vyos-1x-7659c452f8d390773e48e5873552bde601e2fbca.tar.gz vyos-1x-7659c452f8d390773e48e5873552bde601e2fbca.zip |
Merge pull request #2162 from nicolas-fort/T5472
T5472: nat redirect: allow redirection without defining redirected port
Diffstat (limited to 'python')
-rw-r--r-- | python/vyos/nat.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/python/vyos/nat.py b/python/vyos/nat.py index b6702f7e2..9cbc2b96e 100644 --- a/python/vyos/nat.py +++ b/python/vyos/nat.py @@ -56,10 +56,13 @@ def parse_nat_rule(rule_conf, rule_id, nat_type, ipv6=False): elif 'translation' in rule_conf: addr = dict_search_args(rule_conf, 'translation', 'address') port = dict_search_args(rule_conf, 'translation', 'port') - redirect_port = dict_search_args(rule_conf, 'translation', 'redirect', 'port') - if redirect_port: - translation_output = [f'redirect to {redirect_port}'] + if 'redirect' in rule_conf['translation']: + translation_output = [f'redirect'] + redirect_port = dict_search_args(rule_conf, 'translation', 'redirect', 'port') + if redirect_port: + translation_output.append(f'to {redirect_port}') else: + translation_prefix = nat_type[:1] translation_output = [f'{translation_prefix}nat'] |