DaanHoogland closed pull request #2681: Source NAT option on Private Gateway
URL: https://github.com/apache/cloudstack/pull/2681
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/systemvm/debian/opt/cloud/bin/configure.py
b/systemvm/debian/opt/cloud/bin/configure.py
index e023a9fb94e..c8e3ff6e504 100755
--- a/systemvm/debian/opt/cloud/bin/configure.py
+++ b/systemvm/debian/opt/cloud/bin/configure.py
@@ -937,12 +937,9 @@ def processStaticNatRule(self, rule):
self.fw.append(["filter", "",
"-A FORWARD -i %s -o eth0 -d %s -m state --state
NEW -j ACCEPT " % (device, rule["internal_ip"])])
- # Configure the hairpin nat
- self.fw.append(["nat", "front",
- "-A PREROUTING -d %s -i eth0 -j DNAT --to-destination
%s" % (rule["public_ip"], rule["internal_ip"])])
-
- self.fw.append(["nat", "front", "-A POSTROUTING -s %s -d %s -j SNAT -o
eth0 --to-source %s" %
- (self.getNetworkByIp(rule['internal_ip']),
rule["internal_ip"], self.getGuestIp())])
+ # 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())])
class IpTablesExecutor:
diff --git a/systemvm/debian/opt/cloud/bin/cs/CsAddress.py
b/systemvm/debian/opt/cloud/bin/cs/CsAddress.py
index 3212dff71ee..10b6d3cfdbe 100755
--- a/systemvm/debian/opt/cloud/bin/cs/CsAddress.py
+++ b/systemvm/debian/opt/cloud/bin/cs/CsAddress.py
@@ -476,9 +476,10 @@ def fw_vpcrouter(self):
self.fw.append(["", "front", "-A NETWORK_STATS_%s -o %s -s %s" %
("eth1", "eth1", guestNetworkCidr)])
- self.fw.append(["nat", "front",
- "-A POSTROUTING -s %s -o %s -j SNAT --to-source
%s" %
- (guestNetworkCidr, self.dev,
self.address['public_ip'])])
+ if self.address["source_nat"]:
+ self.fw.append(["nat", "front",
+ "-A POSTROUTING -o %s -j SNAT --to-source %s" %
+ (self.dev, self.address['public_ip'])])
if self.get_type() in ["public"]:
self.fw.append(
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services