From f0ae034faa74a90ee3c98d31bfd8df2ae0513c7f Mon Sep 17 00:00:00 2001
From: Nicolas Fort <nicolasfort1988@gmail.com>
Date: Wed, 23 Aug 2023 13:00:27 +0000
Subject: T5472: nat redirect: allow redirection without defining redirected
 port

---
 python/vyos/nat.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

(limited to 'python')

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']
 
-- 
cgit v1.2.3