Skip to content

Commit 2c2426c

Browse files
committed
CLOUDSTACK-2680 Fix Private Gateway SNAT when using guest interface
1 parent 8798014 commit 2c2426c

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

systemvm/debian/opt/cloud/bin/configure.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -937,12 +937,9 @@ def processStaticNatRule(self, rule):
937937
self.fw.append(["filter", "",
938938
"-A FORWARD -i %s -o eth0 -d %s -m state --state NEW -j ACCEPT " % (device, rule["internal_ip"])])
939939

940-
# Configure the hairpin nat
941-
self.fw.append(["nat", "front",
942-
"-A PREROUTING -d %s -i eth0 -j DNAT --to-destination %s" % (rule["public_ip"], rule["internal_ip"])])
943-
944-
self.fw.append(["nat", "front", "-A POSTROUTING -s %s -d %s -j SNAT -o eth0 --to-source %s" %
945-
(self.getNetworkByIp(rule['internal_ip']), rule["internal_ip"], self.getGuestIp())])
940+
# Configure the hairpin snat
941+
self.fw.append(["nat", "front", "-A POSTROUTING -s %s -d %s -j SNAT -o %s --to-source %s" %
942+
(self.getNetworkByIp(rule['internal_ip']), rule["internal_ip"], self.getDeviceByIp(rule["internal_ip"]), self.getGuestIp())])
946943

947944

948945
class IpTablesExecutor:

systemvm/debian/opt/cloud/bin/cs/CsAddress.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,10 @@ def fw_vpcrouter(self):
476476
self.fw.append(["", "front", "-A NETWORK_STATS_%s -o %s -s %s" %
477477
("eth1", "eth1", guestNetworkCidr)])
478478

479-
self.fw.append(["nat", "front",
480-
"-A POSTROUTING -s %s -o %s -j SNAT --to-source %s" %
481-
(guestNetworkCidr, self.dev, self.address['public_ip'])])
479+
if self.address["source_nat"]:
480+
self.fw.append(["nat", "front",
481+
"-A POSTROUTING -o %s -j SNAT --to-source %s" %
482+
(self.dev, self.address['public_ip'])])
482483

483484
if self.get_type() in ["public"]:
484485
self.fw.append(

0 commit comments

Comments
 (0)