From 70f2420e541c3d25929c007994caf409ae415f2b Mon Sep 17 00:00:00 2001 From: Rakesh Date: Thu, 2 Sep 2021 10:29:46 +0200 Subject: [PATCH] router: Use source IP from subnet for snat (#5376) 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. Co-authored-by: Rakesh Venkatesh --- 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 3957d0e0f54..53e9452d0b9 100755 --- a/systemvm/debian/opt/cloud/bin/configure.py +++ b/systemvm/debian/opt/cloud/bin/configure.py @@ -1008,7 +1008,7 @@ class CsForwardingRules(CsDataBag): # 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: