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 <rakeshv@apache.org>
This commit is contained in:
Rakesh 2021-09-02 10:29:46 +02:00 committed by GitHub
parent 989a46850e
commit 70f2420e54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: