summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli
diff options
context:
space:
mode:
authorChristian Breunig <christian@breunig.cc>2023-07-22 08:41:10 +0200
committerGitHub <noreply@github.com>2023-07-22 08:41:10 +0200
commit0ca6a8c2fdcdd5b2efe875831236504c161099a4 (patch)
tree7c07a345e193114d0a12d1486a5f51c86a9256f4 /smoketest/scripts/cli
parentc59765163885cc5bc54df9b194366f8713d065a1 (diff)
parent4c61fa82f59e26023993be56be1ff9bf0cb5251e (diff)
downloadvyos-1x-0ca6a8c2fdcdd5b2efe875831236504c161099a4.tar.gz
vyos-1x-0ca6a8c2fdcdd5b2efe875831236504c161099a4.zip
Merge pull request #2100 from nicolas-fort/T4889
T4889: NAT Redirect: adddestination nat redirection (to local host) feature.
Diffstat (limited to 'smoketest/scripts/cli')
-rwxr-xr-xsmoketest/scripts/cli/test_nat.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/smoketest/scripts/cli/test_nat.py b/smoketest/scripts/cli/test_nat.py
index 02fa03f7b..28d566eba 100755
--- a/smoketest/scripts/cli/test_nat.py
+++ b/smoketest/scripts/cli/test_nat.py
@@ -231,5 +231,26 @@ class TestNAT(VyOSUnitTestSHIM.TestCase):
self.verify_nftables(nftables_search, 'ip vyos_static_nat')
+ def test_dnat_redirect(self):
+ dst_addr_1 = '10.0.1.1'
+ dest_port = '5122'
+ protocol = 'tcp'
+ redirected_port = '22'
+ ifname = 'eth0'
+
+ self.cli_set(dst_path + ['rule', '10', 'destination', 'address', dst_addr_1])
+ self.cli_set(dst_path + ['rule', '10', 'destination', 'port', dest_port])
+ self.cli_set(dst_path + ['rule', '10', 'protocol', protocol])
+ self.cli_set(dst_path + ['rule', '10', 'inbound-interface', ifname])
+ self.cli_set(dst_path + ['rule', '10', 'translation', 'redirect', 'port', redirected_port])
+
+ self.cli_commit()
+
+ nftables_search = [
+ [f'iifname "{ifname}"', f'ip daddr {dst_addr_1}', f'{protocol} dport {dest_port}', f'redirect to :{redirected_port}']
+ ]
+
+ self.verify_nftables(nftables_search, 'ip vyos_nat')
+
if __name__ == '__main__':
unittest.main(verbosity=2)