From 681517077654308734755cf4706665549234c6ae Mon Sep 17 00:00:00 2001 From: Rakesh Venkatesh Date: Thu, 26 Aug 2021 10:32:47 +0200 Subject: [PATCH] Use source IP from subnet for snat When snat is configured on a vm in a subnet then the source ip should be taken from the same subnet rather than from random other subnet. --- systemvm/debian/opt/cloud/bin/configure.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systemvm/debian/opt/cloud/bin/configure.py b/systemvm/debian/opt/cloud/bin/configure.py index cafd739d7cab..c078309290ff 100755 --- a/systemvm/debian/opt/cloud/bin/configure.py +++ b/systemvm/debian/opt/cloud/bin/configure.py @@ -1008,7 +1008,7 @@ def processStaticNatRule(self, rule): # Configure the hairpin snat self.fw.append(["nat", "front", "-A POSTROUTING -s %s -d %s -j SNAT -o %s --to-source %s" % - (self.getNetworkByIp(rule['internal_ip']), rule["internal_ip"], self.getDeviceByIp(rule["internal_ip"]), self.getGuestIp())]) + (self.getNetworkByIp(rule['internal_ip']), rule["internal_ip"], self.getDeviceByIp(rule["internal_ip"]), self.getGuestIpByIp(rule["internal_ip"]))]) class IpTablesExecutor: